Singleton Object Create of object? [Resolved]

Posted by Naga116 under ASP.NET on 7/28/2011 | Points: 10 | Views : 994 | Status : [Member] | Replies : 3
Interviewer asked create a singleton Object to A Class. How to create a singleton Object to Class A. Please provide...
A
{
//Some code
}

B:A
{
//code
}

C:B
{
// do some code
}

Nagaraju


Responses

Posted by: Hmanjarawala on: 8/3/2011 [Member] Bronze | Points: 50

Up
0
Down

Resolved
In order to create singletone object of any class, defines it's constructor to private
so Re-write ur class A like

class A
{
private static A a;
private A(){}
public static A CreateInstance()
{
if a = null
a = new A();
return a;
}
}

Hope this post will help you.

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Musuoka on: 8/3/2011 [Member] Starter | Points: 25

Up
0
Down
[URL=http://www.oakleyfactory0utlet.com/]oakley sunglass outlet[/URL]
[URL=http://www.oakleyfactory0utlet.com/]oakley sunglasses discounted[/URL]
[URL=http://www.oakley0utlet.co.uk/]discounted oakley tig[/URL]
[URL=http://www.oakley0utlet.co.uk/]buy oakley[/URL]

[URL=http://www.oakleysunglass0utlet.com/]oakley store[/URL]

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Musuoka on: 8/3/2011 [Member] Starter | Points: 25

Up
0
Down
<a href="http://www.oakley0utlet.co.uk/">discounted oakley tig</a>
<a href="http://www.oakley0utlet.co.uk/">buy oakley</a>

[URL=http://www.oakleysunglass0utlet.com/]oakley store[/URL]

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response