public static RefType _refVar;
public static void Main()
var a = new RefType("Created In Main");
Console.WriteLine("Вызов GetNoRef: " + TextCache.GetNoRef(a));
Console.WriteLine("Использование класса после GetNoRef: " + a.Text);
Console.WriteLine("Вызов GetRef: " +TextCache.GetRef(ref a));
Console.WriteLine("Использование класса после GetRef: " + a.Text);
public RefType(string text)
public string Text {get;set;}
public static class TextCache
private static RefType _refType;
public static string GetRef(ref RefType refType)
_refType = _refType ?? new RefType("Created In Cache");
public static string GetNoRef(RefType refType)
_refType = _refType ?? new RefType("Created In Cache");