Created
June 26, 2014 18:57
-
-
Save wtuts/077e7c22a23ae35f5459 to your computer and use it in GitHub Desktop.
Isolated Storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Save_composite_object_button_click(object sender, RoutedEventArgs e) | |
{ | |
//Data object to be saved | |
Resultclass obj = new Resultclass(); | |
obj.name = "Vivek"; | |
obj.marks = 98; | |
//Declare the instance of Isolated Storage settings | |
var settings = IsolatedStorageSettings.ApplicationSettings; | |
//Key is composite and object is composite of type Resultclass | |
settings.Add("composite", obj); | |
} | |
//Note:Just click on the above save button once because every time you click on it a error will occur | |
//Because the value of each Key pair must be unique | |
private void Read_composite_object_click(object sender, RoutedEventArgs e) | |
{ | |
//Declare a object of Result class which will read the values from Isolated storage | |
Resultclass myobj; | |
//Declare the instance of Isolated Storage settings | |
var settings = IsolatedStorageSettings.ApplicationSettings; | |
//Read the value | |
//check if target object exists with specific key value | |
if (settings.Contains("composite")) | |
{ | |
settings.TryGetValue<Resultclass>("composite", out myobj); | |
Displayblock.Text = "Name of student is " + myobj.name + " and Marks are " + myobj.marks.ToString(); | |
} | |
else | |
{ | |
Displayblock.Text = "First save the values to isolated Storage.Click on the save button."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment