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