Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
QuestionA timer func problem??? Pin
cemlouis2-Oct-04 14:08
cemlouis2-Oct-04 14:08 
AnswerRe: A timer func problem??? Pin
partyganger2-Oct-04 16:21
partyganger2-Oct-04 16:21 
Questionadding to the byte[] ? Pin
SniperED0072-Oct-04 10:00
SniperED0072-Oct-04 10:00 
AnswerRe: adding to the byte[] ? Pin
Nnamdi Onyeyiri2-Oct-04 23:58
Nnamdi Onyeyiri2-Oct-04 23:58 
GeneralColor of Column Headers in a DataGrid Pin
MarkMokris2-Oct-04 7:44
MarkMokris2-Oct-04 7:44 
GeneralRe: Color of Column Headers in a DataGrid Pin
sreejith ss nair3-Oct-04 19:50
sreejith ss nair3-Oct-04 19:50 
GeneralBest way to store and access Global variables Pin
Zapss2-Oct-04 3:02
Zapss2-Oct-04 3:02 
GeneralRe: Best way to store and access Global variables Pin
Colin Angus Mackay2-Oct-04 4:00
Colin Angus Mackay2-Oct-04 4:00 
C# does not support global variables per se, it isn't good a object oriented design to have lots of global variables floating around. However, you can create static variables on a class which are accessible globally. For example:

public class GlobalConfiguration
{
    private static int _sqlServerTimeout = 60;

    public static int SqlServerTimeout
    {
        get
        {
            return _sqlServerTimeout;
        }
        set
        {
            _sqlServerTimeout = value;
        }
    }
}


Of course, you don't NEED to wrap the variable in a property, but it is good practice to do so. You can add extra validation in the setter, and the getter can internally operate a lazy lookup if the variable is not often required, but getting the value takes time (Once you have generated the value the first time you can store it, so that the next time you need the value it can be returned quickly).


Do you want to know more?


Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
GeneralRe: Best way to store and access Global variables Pin
Andres Coder3-Oct-04 6:14
Andres Coder3-Oct-04 6:14 
GeneralDesign Optimization Pin
sreejith ss nair2-Oct-04 2:56
sreejith ss nair2-Oct-04 2:56 
GeneralRe: Design Optimization Pin
Colin Angus Mackay2-Oct-04 4:11
Colin Angus Mackay2-Oct-04 4:11 
GeneralRe: Design Optimization Pin
sreejith ss nair2-Oct-04 18:43
sreejith ss nair2-Oct-04 18:43 
GeneralRe: Design Optimization Pin
Nnamdi Onyeyiri2-Oct-04 12:14
Nnamdi Onyeyiri2-Oct-04 12:14 
GeneralRe: Design Optimization Pin
sreejith ss nair2-Oct-04 18:43
sreejith ss nair2-Oct-04 18:43 
GeneralRe: Design Optimization Pin
hatim_ali3-Oct-04 19:33
hatim_ali3-Oct-04 19:33 
GeneralRe: Design Optimization Pin
sreejith ss nair3-Oct-04 19:48
sreejith ss nair3-Oct-04 19:48 
GeneralRe: Design Optimization Pin
Dave Kreskowiak4-Oct-04 7:07
mveDave Kreskowiak4-Oct-04 7:07 
Generalimage.saveadd function Pin
hudhud2-Oct-04 2:52
hudhud2-Oct-04 2:52 
GeneralRename XmlNode in Dom Pin
Anonymous2-Oct-04 1:52
Anonymous2-Oct-04 1:52 
GeneralRe: Rename XmlNode in Dom Pin
partyganger2-Oct-04 16:34
partyganger2-Oct-04 16:34 
AnswerRe: Rename XmlNode in Dom Pin
CMercs25-Aug-10 4:26
CMercs25-Aug-10 4:26 
GeneralSingleton Pin
hatim_ali2-Oct-04 0:46
hatim_ali2-Oct-04 0:46 
GeneralRe: Singleton Pin
Brian Nottingham2-Oct-04 18:06
Brian Nottingham2-Oct-04 18:06 
Generalusing system.xml Pin
Mridang Agarwalla2-Oct-04 0:16
Mridang Agarwalla2-Oct-04 0:16 
GeneralRe: using system.xml Pin
hatim_ali2-Oct-04 0:33
hatim_ali2-Oct-04 0: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.