Click here to Skip to main content
15,911,531 members
Home / Discussions / C#
   

C#

 
GeneralRe: Product Registration and Keys Pin
AB777131-Jul-06 4:26
AB777131-Jul-06 4:26 
AnswerRe: Product Registration and Keys Pin
Ennis Ray Lynch, Jr.31-Jul-06 4:33
Ennis Ray Lynch, Jr.31-Jul-06 4:33 
AnswerRe: Product Registration and Keys Pin
LongRange.Shooter31-Jul-06 5:16
LongRange.Shooter31-Jul-06 5:16 
AnswerRe: Product Registration and Keys Pin
Steve Maier31-Jul-06 7:32
professionalSteve Maier31-Jul-06 7:32 
QuestionInstaller Dilemma!! Pin
Willem_Le_Roux31-Jul-06 2:26
Willem_Le_Roux31-Jul-06 2:26 
AnswerRe: Installer Dilemma!! Pin
LongRange.Shooter31-Jul-06 5:17
LongRange.Shooter31-Jul-06 5:17 
QuestionRe: Installer Dilemma!! [modified] Pin
Willem_Le_Roux1-Aug-06 0:45
Willem_Le_Roux1-Aug-06 0:45 
QuestionSingleton object doesn't detroy when i assign it to null. Pin
madhusri31-Jul-06 2:07
madhusri31-Jul-06 2:07 
Here is the code sample of sington class and their clients
<br />
public class single<br />
    {<br />
        public string str = "Hello";<br />
        private static single s = null;<br />
<br />
        private single()<br />
        {<br />
        }<br />
<br />
        public static single CreateInstance()<br />
        {<br />
            if (s == null)<br />
                s = new single();<br />
<br />
            return s;<br />
        }<br />
<br />
        public string Get()<br />
        {<br />
            return str;<br />
        }<br />
    }<br />
    class Program<br />
    {<br />
        static void Main(string[] args)<br />
        {<br />
            single i = single.CreateInstance();<br />
<br />
            string str1 = i.Get();<br />
            Console.WriteLine(str1);<br />
<br />
            i.str = "World";<br />
<br />
            i = null;<br />
            single j = single.CreateInstance();<br />
<br />
            string str2 = j.Get();<br />
            Console.WriteLine(str2);<br />
<br />
            j = single.CreateInstance();<br />
            j.str = "New";<br />
            string str3 = j.Get();<br />
            Console.WriteLine(str3);<br />
<br />
            <br />
        }<br />
    }<br />

Output::
Hello
World
New

But it should be
Hello
Hello
New

since we assigned i=null then the singleton must be destroyed and new instance should be created when j = single.CreateInstance(); executed right?

Thanks and Regards
Madhu

AnswerRe: Singleton object doesn't detroy when i assign it to null. Pin
Ravi Bhavnani31-Jul-06 2:19
professionalRavi Bhavnani31-Jul-06 2:19 
AnswerRe: Singleton object doesn't detroy when i assign it to null. Pin
leppie31-Jul-06 3:23
leppie31-Jul-06 3:23 
GeneralRe: Singleton object doesn't detroy when i assign it to null. Pin
madhusri31-Jul-06 5:35
madhusri31-Jul-06 5:35 
GeneralNot necessarily Pin
Ennis Ray Lynch, Jr.31-Jul-06 7:42
Ennis Ray Lynch, Jr.31-Jul-06 7:42 
GeneralRe: Not necessarily Pin
engsrini31-Jul-06 8:15
engsrini31-Jul-06 8:15 
GeneralThe GC has to run twice Pin
Ennis Ray Lynch, Jr.31-Jul-06 8:37
Ennis Ray Lynch, Jr.31-Jul-06 8:37 
GeneralRe: Singleton object doesn't detroy when i assign it to null. Pin
Colin Angus Mackay31-Jul-06 8:01
Colin Angus Mackay31-Jul-06 8:01 
GeneralRe: Singleton object doesn't detroy when i assign it to null. Pin
engsrini31-Jul-06 8:23
engsrini31-Jul-06 8:23 
AnswerRe: Singleton object doesn't detroy when i assign it to null. Pin
V.31-Jul-06 4:10
professionalV.31-Jul-06 4:10 
AnswerRe: Singleton object doesn't detroy when i assign it to null. Pin
Colin Angus Mackay31-Jul-06 5:15
Colin Angus Mackay31-Jul-06 5:15 
QuestionCtrl + B in RichtextBox Pin
AB777131-Jul-06 2:02
AB777131-Jul-06 2:02 
AnswerRe: Ctrl + B in RichtextBox Pin
stancrm31-Jul-06 2:16
stancrm31-Jul-06 2:16 
GeneralRe: Ctrl + B in RichtextBox Pin
AB777131-Jul-06 2:24
AB777131-Jul-06 2:24 
GeneralRe: Ctrl + B in RichtextBox Pin
Empires31-Jul-06 2:28
Empires31-Jul-06 2:28 
GeneralRe: Ctrl + B in RichtextBox Pin
AB777131-Jul-06 2:59
AB777131-Jul-06 2:59 
GeneralRe: Ctrl + B in RichtextBox Pin
AB777131-Jul-06 2:37
AB777131-Jul-06 2:37 
GeneralRe: Ctrl + B in RichtextBox Pin
stancrm31-Jul-06 3:27
stancrm31-Jul-06 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.