Related: How do I create a static local variable in Java?
Pardon if this is a duplicate; I was pretty sure this would have been
Not in C#, only in Visual Basic .NET:
Sub DoSomething() Static obj As Object If obj Is Nothing Then obj = New Object Console.WriteLine(obj.ToString()) End Sub
VB.NET have lot of nice things that C# does not have, thats why I choose VB.NET.