Click here to Skip to main content
15,920,688 members
Home / Discussions / C#
   

C#

 
GeneralRe: String tokenizer in C# Pin
leppie22-Dec-03 6:35
leppie22-Dec-03 6:35 
GeneralRe: String tokenizer in C# Pin
Larry Antram22-Dec-03 11:51
Larry Antram22-Dec-03 11:51 
GeneralC# API to generate PDF files from XSL:FO Pin
MrEyes22-Dec-03 4:21
MrEyes22-Dec-03 4:21 
GeneralRe: C# API to generate PDF files from XSL:FO Pin
Philip Fitzsimons22-Dec-03 4:37
Philip Fitzsimons22-Dec-03 4:37 
GeneralRe: C# API to generate PDF files from XSL:FO Pin
MrEyes22-Dec-03 5:17
MrEyes22-Dec-03 5:17 
Generalglobal variable in c# Pin
Anonymous22-Dec-03 4:06
Anonymous22-Dec-03 4:06 
GeneralRe: global variable in c# Pin
ThoWeib22-Dec-03 4:28
ThoWeib22-Dec-03 4:28 
GeneralRe: global variable in c# Pin
Heath Stewart22-Dec-03 4:30
protectorHeath Stewart22-Dec-03 4:30 
In .NET (true for any language that targets the CLR) there is no such thing as global variables. Instead, though, you can create a class with static fields or properties (properties are usually recommended because you can validate inputs and use logic in your get or set accessors that access a private field. This has the same result, though, at least per AppDomain (if you need a "global" to span multiple AppDomains, you should consider a ContextBoundObject).
public class Globals
{
  private static object someProperty;
  // Prevents instantiation
  private Globals()
  {
  }
  public static object SomeProperty
  {
    get { return someProperty; }
    set { someProperty = value; }
  }
}
If you need the power of a singleton, search the comments of this forum for a recent thread discussing various options. Just use the keyword "singleton", of course.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralConfiguration file Pin
Mazdak22-Dec-03 3:31
Mazdak22-Dec-03 3:31 
GeneralRe: Configuration file Pin
Heath Stewart22-Dec-03 4:26
protectorHeath Stewart22-Dec-03 4:26 
QuestionRegistry or Special Folders? Pin
Ken Galer22-Dec-03 3:25
Ken Galer22-Dec-03 3:25 
AnswerRe: Registry or Special Folders? Pin
Heath Stewart22-Dec-03 4:21
protectorHeath Stewart22-Dec-03 4:21 
Generalkeyboard event listener Pin
hazzem elrefai22-Dec-03 1:48
hazzem elrefai22-Dec-03 1:48 
GeneralRe: keyboard event listener Pin
hazzem elrefai22-Dec-03 1:49
hazzem elrefai22-Dec-03 1:49 
GeneralRe: keyboard event listener Pin
Heath Stewart22-Dec-03 4:16
protectorHeath Stewart22-Dec-03 4:16 
GeneralRe: keyboard event listener Pin
hazzem elrefai22-Dec-03 20:20
hazzem elrefai22-Dec-03 20:20 
GeneralRe: keyboard event listener Pin
Heath Stewart23-Dec-03 2:33
protectorHeath Stewart23-Dec-03 2:33 
Questionhow to set 8 px gap at front and back of the button's caption Pin
my_res22-Dec-03 1:27
my_res22-Dec-03 1:27 
AnswerRe: how to set 8 px gap at front and back of the button's caption Pin
Heath Stewart22-Dec-03 4:15
protectorHeath Stewart22-Dec-03 4:15 
GeneralCSharp Certification Pin
Member 33502222-Dec-03 0:07
Member 33502222-Dec-03 0:07 
GeneralRe: CSharp Certification Pin
Kannan Kalyanaraman22-Dec-03 0:09
Kannan Kalyanaraman22-Dec-03 0:09 
GeneralRe: CSharp Certification Pin
Heath Stewart22-Dec-03 4:11
protectorHeath Stewart22-Dec-03 4:11 
GeneralProblem in opening Crystal Report after deploying with C# application in windows 98 Pin
KRathor21-Dec-03 20:09
KRathor21-Dec-03 20:09 
GeneralRe: Problem in opening Crystal Report after deploying with C# application in windows 98 Pin
Heath Stewart22-Dec-03 4:02
protectorHeath Stewart22-Dec-03 4:02 
GeneralEditor - HTML Pin
Member 37804121-Dec-03 18:29
Member 37804121-Dec-03 18:29 

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.