Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    When writing an example, please write a real one rather than pseudocode. I'd also advise finding a good C# tutorial for the meaning of static. Commented Jan 14, 2018 at 16:35
  • 1
    If you're dealing with a properly implemented singleton then the constructor will only be run once and you're only going to be dealing with one instance. However you have not included all the code so we can not say for sure why you see that behavior. Commented Jan 14, 2018 at 16:44
  • I'm not sure, what "getInstance" does. From the code shown above, I see no singleton. Assuming that getInstance creates a new instance of the Singletonclass, the countervariable is incremented wht every new instance. The =0assignment in the declaration line of counter is only executed once, at program startup, since counteris static. Commented Jan 14, 2018 at 16:51
  • Thanks, Heinz Kessler. Commented Jan 15, 2018 at 15:23