I have a class which needs to be a Singleton. It must also be able to load and save its field data in an xml file.
The following method will return a new instance,
why dont you have something like
public Class TheClassHoldingYourObject
{
private static XmlSerializer _instance;
public static Settings Load()
{
if(_instance != null) return _instance
using (Stream stream = File.OpenRead(FileName))
{
XmlSerializer serializer = new XmlSerializer(typeof(Settings));
return (Settings)serializer.Deserialize(stream);
}
}
}
Now you will always get the same instance