Click here to Skip to main content
15,886,518 members
Home / Discussions / C#
   

C#

 
QuestionHangMan C# need help! Pin
Munteanu Silviu28-Mar-15 7:21
Munteanu Silviu28-Mar-15 7:21 
AnswerRe: HangMan C# need help! Pin
Sascha Lefèvre28-Mar-15 8:23
professionalSascha Lefèvre28-Mar-15 8:23 
AnswerRe: HangMan C# need help! Pin
Bjørn8-Apr-15 4:24
Bjørn8-Apr-15 4:24 
QuestionPPPoe connection creation in c# Pin
KARFER28-Mar-15 4:00
KARFER28-Mar-15 4:00 
Questionlocalazation simulation Pin
huthiafa27-Mar-15 23:33
huthiafa27-Mar-15 23:33 
GeneralRe: localazation simulation Pin
Richard MacCutchan27-Mar-15 23:57
mveRichard MacCutchan27-Mar-15 23:57 
QuestionGlobal variable in C# Pin
aahamdan27-Mar-15 23:24
aahamdan27-Mar-15 23:24 
AnswerRe: Global variable in C# Pin
OriginalGriff28-Mar-15 0:27
mveOriginalGriff28-Mar-15 0:27 
C# doesn't have global variables: the closest you can come is to create a static property of a Database class and use that:
C#
class Database
   {
   public static SqlConnection Connection { get; private set; }
   public void Create(string strConnect)
       {
       Connection = new SqlConnection(strConnect);
       Connection.Open();
       }
   }
But personally, I wouldn't do that - it encourages you to maintain a connection for teh life of the application which is a pretty poor practice. It also means that you only get one connection, so some operations are not possible - any INSERT or UPDATE while processing a SqlDataReader for example. I'd create the connections as I need them, inside a using block so that they are closed and disposed when I'm done.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: Global variable in C# Pin
aahamdan4-Apr-15 4:07
aahamdan4-Apr-15 4:07 
GeneralRe: Global variable in C# Pin
OriginalGriff4-Apr-15 4:26
mveOriginalGriff4-Apr-15 4:26 
AnswerRe: Global variable in C# Pin
Afzaal Ahmad Zeeshan28-Mar-15 17:32
professionalAfzaal Ahmad Zeeshan28-Mar-15 17:32 
GeneralRe: Global variable in C# Pin
aahamdan4-Apr-15 4:06
aahamdan4-Apr-15 4:06 
QuestionMobile agent data gathering in WSNs Pin
huthiafa27-Mar-15 22:25
huthiafa27-Mar-15 22:25 
QuestionEnumeration in C#,Different Input returning Same enumeration Pin
KK Kod27-Mar-15 5:01
KK Kod27-Mar-15 5:01 
AnswerRe: Enumeration in C#,Different Input returning Same enumeration Pin
Sascha Lefèvre27-Mar-15 5:16
professionalSascha Lefèvre27-Mar-15 5:16 
GeneralRe: Enumeration in C#,Different Input returning Same enumeration Pin
KK Kod27-Mar-15 5:25
KK Kod27-Mar-15 5:25 
AnswerRe: Enumeration in C#,Different Input returning Same enumeration Pin
Eddy Vluggen27-Mar-15 5:22
professionalEddy Vluggen27-Mar-15 5:22 
GeneralRe: Enumeration in C#,Different Input returning Same enumeration Pin
KK Kod27-Mar-15 5:26
KK Kod27-Mar-15 5:26 
GeneralRe: Enumeration in C#,Different Input returning Same enumeration Pin
Eddy Vluggen27-Mar-15 6:20
professionalEddy Vluggen27-Mar-15 6:20 
AnswerRe: Enumeration in C#,Different Input returning Same enumeration Pin
PIEBALDconsult27-Mar-15 15:52
mvePIEBALDconsult27-Mar-15 15:52 
QuestionImage segmentation - show or hide clusters Pin
Member 1133638227-Mar-15 4:15
Member 1133638227-Mar-15 4:15 
AnswerRe: Image segmentation - show or hide clusters Pin
Eddy Vluggen27-Mar-15 9:29
professionalEddy Vluggen27-Mar-15 9:29 
QuestionI found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258026-Mar-15 15:35
patrickjiang258026-Mar-15 15:35 
AnswerRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
Afzaal Ahmad Zeeshan26-Mar-15 17:01
professionalAfzaal Ahmad Zeeshan26-Mar-15 17:01 
GeneralRe: I found some issues in coding but I don't know how to solve them. Could you give me some advices ? Pin
patrickjiang258026-Mar-15 22:27
patrickjiang258026-Mar-15 22: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.