我给出了以下代码示例:
public static class A
{
private static B _b;
public static B GetB
{
get
{
if(_b == null)
{
_b = B.load();
}
return _b;
}
}
public static void Save()
{
if(_b == null)
{
_b = B.load();
}
_b.Save()
}
}
public class B
{
public string Value{ get; set;}
public void Save()
{
//value is being save to somewhere
}
public static B load()
{
B b = new B();
// .....
//b.Value is loaded …Run Code Online (Sandbox Code Playgroud) c# ×1