Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
GeneralRe: Graphics.MeasureString Pin
compbssn200323-Mar-04 19:20
compbssn200323-Mar-04 19:20 
GeneralExposing constituent control properties in VS.NET Pin
Matt Davison23-Mar-04 5:07
Matt Davison23-Mar-04 5:07 
GeneralRe: Exposing constituent control properties in VS.NET Pin
Heath Stewart23-Mar-04 5:30
protectorHeath Stewart23-Mar-04 5:30 
GeneralRe: Exposing constituent control properties in VS.NET Pin
Heath Stewart23-Mar-04 8:16
protectorHeath Stewart23-Mar-04 8:16 
QuestionHow can I do the following... Pin
profoundwhispers23-Mar-04 4:36
profoundwhispers23-Mar-04 4:36 
AnswerRe: How can I do the following... Pin
Heath Stewart23-Mar-04 4:54
protectorHeath Stewart23-Mar-04 4:54 
GeneralRe: How can I do the following... Pin
profoundwhispers23-Mar-04 5:08
profoundwhispers23-Mar-04 5:08 
GeneralRe: How can I do the following... Pin
Heath Stewart23-Mar-04 5:26
protectorHeath Stewart23-Mar-04 5:26 
A singleton is a single instance of an object. You can either use a simple approach like:
public sealed class MySingleton
{
  private static MySingleton instance;
  private int i;
  private MySingleton()
  {
    i = 1;
  }
  public static MySingleton Instance // Often private, though
  {
    get
    {
      if (instance == null)
        lock (typeof(MySingleton))
          if (instance == null)
            instance = new MySingleton();
      return instance;
    }
  }
  public static int SomeMethod()
  {
    return Instance.i; // Use Instance, not instance to make sure it's init'd.
  }
}
Or you could use a ContextBoundObject with its own RealProxy derivative that returns the same instance when someone tries to instantiate your object.

 

Microsoft MVP, Visual C#
My Articles
Generalinput a barecode Pin
tonaxxl23-Mar-04 4:18
tonaxxl23-Mar-04 4:18 
GeneralRe: input a barecode Pin
Dave Kreskowiak23-Mar-04 4:26
mveDave Kreskowiak23-Mar-04 4:26 
GeneralRe: input a barecode Pin
tonaxxl23-Mar-04 4:35
tonaxxl23-Mar-04 4:35 
GeneralRe: input a barecode Pin
Dave Kreskowiak23-Mar-04 5:24
mveDave Kreskowiak23-Mar-04 5:24 
GeneralRe: input a barecode Pin
tonaxxl23-Mar-04 16:42
tonaxxl23-Mar-04 16:42 
GeneralRe: input a barecode Pin
Dave Kreskowiak24-Mar-04 0:18
mveDave Kreskowiak24-Mar-04 0:18 
GeneralRe: input a barecode Pin
tonaxxl25-Mar-04 17:25
tonaxxl25-Mar-04 17:25 
GeneralRe: input a barecode Pin
Dave Kreskowiak26-Mar-04 2:28
mveDave Kreskowiak26-Mar-04 2:28 
GeneralRe: input a barecode Pin
tonaxxl26-Mar-04 6:41
tonaxxl26-Mar-04 6:41 
GeneralRe: input a barecode Pin
Apusnaias23-Mar-04 23:27
Apusnaias23-Mar-04 23:27 
GeneralRe: input a barecode Pin
tonaxxl25-Mar-04 17:29
tonaxxl25-Mar-04 17:29 
GeneralRe: input a barecode Pin
cjengler24-Mar-04 0:25
cjengler24-Mar-04 0:25 
GeneralIcons included in EXE Pin
Guinness4Strength23-Mar-04 3:35
Guinness4Strength23-Mar-04 3:35 
GeneralRe: Icons included in EXE Pin
Heath Stewart23-Mar-04 3:45
protectorHeath Stewart23-Mar-04 3:45 
GeneralRe: Icons included in EXE Pin
Guinness4Strength23-Mar-04 4:02
Guinness4Strength23-Mar-04 4:02 
GeneralWeb Service Remote Installation Pin
Braulio Dez23-Mar-04 2:16
Braulio Dez23-Mar-04 2:16 
GeneralRe: Web Service Remote Installation Pin
Mazdak23-Mar-04 2:33
Mazdak23-Mar-04 2:33 

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.