I need an object through out my application. To achieve this I have two approach
define the object as static.
public class App { public static MyClass myObject; }
Make the class Singleton
public class MyClass { private MyClass() { } public static MyClass Instance { get { return Nested.instance; } } class Nested { static Nested() { } internal static readonly MyClass instance = new MyClass(); } }
Can anyone help me with advantages and disadvantages of these two approaches.