My Thoughts & Views

Singleton Class in C#

Posted on: September 13, 2007

1 public sealed class SingletonClass
2 {
3
private SingletonClass()
4
{
5 }
6
7 private static SingletonClass instance = new SingletonClass();
8
9 public static SingletonClass Instance
10 {
11 get
12
{
13
if(instance == null)
14
{
15 instance = new SingletonClass();
16 return instance;
17 }
18
else
19
return instance;
20
}
21
}
22
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: