温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

XamarinEssentials中怎么获取首选项的值

发布时间:2021-07-29 14:37:24 来源:亿速云 阅读:141 作者:Leah 栏目:移动开发

这期内容当中小编将会给大家带来有关XamarinEssentials中怎么获取首选项的值,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

XamarinEssentials教程获取首选项的值

(1)Get(string, bool)方法的语法形式如下:

public static bool Get(string key, bool defaultValue)

(2)Get(string, bool, string)方法的语法形式如下:

public static bool Get(string key, bool defaultValue, string sharedName)

(3)Get(string, double)方法的语法形式如下:

public static double Get(string key, double defaultValue)

(4)Get(string, double, string)方法的语法形式如下:

public static double Get(string key, double defaultValue, string sharedName)

(5)Get(string, float) 方法的语法形式如下:

public static float Get(string key, float defaultValue)

(6)Get(string, float, string)方法的语法形式如下:

public static float Get(string key, float defaultValue, string sharedName)

(7)Get(string, int)方法的语法形式如下:

public static int Get(string key, int defaultValue)

(8)Get(string, int, string)方法的语法形式如下:

public static int Get(string key, int defaultValue, string sharedName)

(9)Get(string, long)方法的语法形式如下:

public static long Get(string key, long defaultValue)

(10)Get(string, long, string)方法的语法形式如下:

public static long Get(string key, long defaultValue, string sharedName)

(11)Get(string, string)方法的语法形式如下:

public static string Get(string key, string defaultValue)

(12)Get(string, string, string)方法的语法形式如下:

public static string Get(string key, string defaultValue, string sharedName)

其中,参数说明如下:

key:首选项的键;

defaultValue:如果键不存在,返回默认值。

sharedName:共享容器名称。

注意:在Get()方法中,如果指定的键存在,则获取指定的默认值。

【示例1-6】下面将获取指定键的值。代码如下:

void Preferences_Get(string key)
{
    Preferences.Get(key, "default_value");                              //获取键对应的值
}

上述就是小编为大家分享的XamarinEssentials中怎么获取首选项的值了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI