After spending countless hours changing my code and removing everything that wont serialize and changing them to strings and writing functions to convert from Font/Color to strings and back again i've got fed up and decided to make my own basic serializer..
private void saveSettings()
{
PropertyInfo[] properties = typeof(settingsObj).GetProperties();
foreach (settingsObj s in settings)
{
foreach (PropertyInfo property in properties)
{
MessageBox.Show(s.[property.Name]);
}
}
}
How do i refer to a variable using a string, in PHP i'd do:
$varIWantToRead = "foobar";
$varName = "varIWantToRead";
print $$varName;
This can easily be done in the exe.config file. Here is a write up from Microsoft:
http://msdn.microsoft.com/en-us/library/aa730869.aspx
You could also create your own class or struct and serialize them into XML:
http://support.microsoft.com/kb/815813
Edit to answer your new question: Im not quite sure I know what your talking about but here we go:
In PHP:
$varIWantToRead = "foobar";
$varName = "varIWantToRead";
print $$varName;
in c#:
string varIWantToRead = "foobar";
string varName = varIWantToRead;
Console.WriteLine(varName); // Outputs foobar
You can use the default behaviour of winforms setting, Application Settings. Take a look at what microsoft says in brief and also goes into more details in another link
XML is a dynamic way of keeping data, there are lots of samples online like this tutorial and this microsoft link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.