private static void Intermediate_OtherThings() { // 1. Static Class Console.WriteLine("========= Static Class / Instance Class ========"); Console.WriteLine(StaticClass.i); Console.WriteLine(StaticClass.sum(1, 1)); Console.WriteLine(NonStaticClass.sum(2, 2)); Console.WriteLine((new NonStaticClass().devide(9, 3))); }
private static void TestStaticFieldInNonStaticClass() { var c = new NonStaticClass(); Assert(43, c.GetPrivateStaticFieldValue()); c.SetPrivateStaticFieldValue(55); Assert(55, c.GetPrivateStaticFieldValue()); }
private static void TestClassReferencingSelfInMethod() { var a = new NonStaticClass() { Value = 3 }; var b = new NonStaticClass() { Value = 7 }; Assert(10, a.CallWithSameClass(b)); }
public int CallWithSameClass(NonStaticClass other) { return(other.Value + this.Value); }
private static void NonStaticClassWithStaticMethod() { NonStaticClass.StaticMethod(1); Assert("StaticMethodInt", Output); }