C# Q'n

Discussion in 'MCAD' started by padam, Apr 2, 2004.

  1. padam

    padam Guest

    hi
    there are two ways of doing this
    first is you can take one static data member in class and
    initialze it with 0 and increment it in the constructor
    and check if the value of the staic variable is greater
    than one generate an error. hope this will help u.

    second one is use singleton keyword (this i never tried
    in c# but this works in c++).


    >-----Original Message-----
    >
    >Does anyone has an answer to this?
    >How can u write a class and restrict that only one

    object
    >can be created?
    >
    >.
    >
     
    padam, Apr 2, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page