Xamarinessentials Tutorial Getting the value of a preference item

Source: Internet
Author: User

Xamarinessentials Tutorial Getting the value of a preference item

If a developer wants to get the value of an item in a preference item, it can be implemented using the Get () method of the preferences class, which gets the value of the specified key. There are 12 forms of this method, which are described in turn.

(1) The syntax form of the Get (string, bool) method is as follows:

public static bool Get (string key, bool defaultvalue)

(2) The syntax form of the Get (string, bool, String) method is as follows:

public static bool Get (string key, bool defaultvalue, String sharedname)

(3) The syntax form of the Get (string, double) method is as follows:

public static double Get (string key, double defaultvalue)

(4) The syntax form of the Get (string, double, string) method is as follows:

public static double Get (string key, double defaultvalue, String sharedname)

(5) The syntax form of the Get (string, float) method is as follows:

public static float Get (string key, float defaultvalue)

(6) The syntax form of the Get (string, float, string) method is as follows:

public static float Get (string key, float defaultvalue, string sharedname)

(7) The syntax form of the Get (string, int) method is as follows:

public static int Get (string key, int defaultvalue)

(8) The syntax form of the Get (string, int, string) method is as follows:

public static int Get (string key, int defaultvalue, string sharedname)

(9) The syntax form of the Get (string, long) method is as follows:

public static long Get (string key, long DefaultValue)

The syntax for the Get (string, Long, String) method is as follows:

public static long Get (string key, long defaultvalue, string sharedname)

The syntax form of the Get (string, String) method is as follows:

public static string Get (string key, String defaultvalue)

The syntax for the Get (string, String, String) method is as follows:

public static string Get (string key, String defaultvalue, String sharedname)

Among them, the parameters are described as follows:

Key: Keys for preferences;

DefaultValue: Returns the default value if the key does not exist.

Sharedname: Shared container name.

Note: In the Get () method, gets the specified default value if the specified key exists.

The value of the specified key is obtained under "Example 1-6". The code is as follows:

void Preferences_get (string  key) {    "default_value");                              // gets the value corresponding to the key }

Xamarinessentials Tutorial Getting the value of a preference item

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.