What happens when we create an instance of class in same class?


This question already has an answer here:


Its not a problem. For example:

public class Class1
  public Class1 Instance {get; set;}

public class Class2
     public void Test()
         Class1 class1 = new Class1();
         var nestedInstance = class1.Instance;

Please read about singleton pattern: https://msdn.microsoft.com/en-us/library/ff650316.aspx This let you to understand this case

Need Your Help

Java String - See if a string contains only numbers and not letters

java string if-statement

I have a string that I load throughout my application, and it changes from numbers to letters and such. I have a simple if statement to see if it contains letters or numbers but, something isn't qu...