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

C#

 
QuestionExecuting an EXE 24hr online Pin
Gjm13-Feb-10 4:56
Gjm13-Feb-10 4:56 
AnswerRe: Executing an EXE 24hr online Pin
Saksida Bojan13-Feb-10 5:10
Saksida Bojan13-Feb-10 5:10 
AnswerRe: Executing an EXE 24hr online Pin
Anurag Gandhi13-Feb-10 6:44
professionalAnurag Gandhi13-Feb-10 6:44 
AnswerDon't repost Pin
Not Active13-Feb-10 7:34
mentorNot Active13-Feb-10 7:34 
QuestionC# nullable types, need clarification Pin
prasadbuddhika13-Feb-10 4:32
prasadbuddhika13-Feb-10 4:32 
AnswerRe: C# nullable types, need clarification [modified] Pin
Saksida Bojan13-Feb-10 4:44
Saksida Bojan13-Feb-10 4:44 
AnswerRe: C# nullable types, need clarification Pin
Luc Pattyn13-Feb-10 5:23
sitebuilderLuc Pattyn13-Feb-10 5:23 
AnswerRe: C# nullable types, need clarification Pin
Alan N13-Feb-10 5:32
Alan N13-Feb-10 5:32 
Hi,
This alternative test clarifies what is going on and I think the take home message is that nullable types must contain a value before a comparison can be made. It's very confusing when x == y is true but x >= y is false and I'm sure this will catch many people out.

static void Main(string[] args) {
  int? x = null; 
  int? y = null;
  Compare(x, y);
  x = 1;
  Compare(x, y);
  Console.ReadLine();
}

private static void Compare(int? x, int? y) {
  Console.WriteLine("{0} >= {1} {2}", x == null ? "null" : x.ToString(), y == null ? "null" : y.ToString(), x >= y);
  Console.WriteLine("{0} > {1} {2}", x == null ? "null" : x.ToString(), y == null ? "null" : y.ToString(), x > y);
  Console.WriteLine("{0} == {1} {2}", x == null ? "null" : x.ToString(), y == null ? "null" : y.ToString(), x == y);
  Console.WriteLine("{0} < {1} {2}", x == null ? "null" : x.ToString(), y == null ? "null" : y.ToString(), x < y);
  Console.WriteLine("{0} <= {1} {2}", x == null ? "null" : x.ToString(), y == null ? "null" : y.ToString(), x <= y);
  Console.WriteLine();
}

/*
null >= null False
null > null False
null == null True
null < null False
null <= null False

1 >= null False
1 > null False
1 == null False
1 < null False
1 <= null False
 */

Alan.
GeneralRe: C# nullable types, need clarification Pin
Luc Pattyn13-Feb-10 6:21
sitebuilderLuc Pattyn13-Feb-10 6:21 
GeneralRe: C# nullable types, need clarification Pin
Alan N13-Feb-10 8:15
Alan N13-Feb-10 8:15 
AnswerRe: C# nullable types, need clarification Pin
Luc Pattyn13-Feb-10 10:26
sitebuilderLuc Pattyn13-Feb-10 10:26 
AnswerRe: C# nullable types, need clarification Pin
Luc Pattyn13-Feb-10 11:03
sitebuilderLuc Pattyn13-Feb-10 11:03 
GeneralRe: C# nullable types, need clarification Pin
prasadbuddhika14-Feb-10 16:38
prasadbuddhika14-Feb-10 16:38 
QuestionDrag form by panel Pin
Scalee13-Feb-10 3:29
Scalee13-Feb-10 3:29 
AnswerRe: Drag form by panel Pin
Saksida Bojan13-Feb-10 3:33
Saksida Bojan13-Feb-10 3:33 
Questionplease help me i want to file send Pin
Member 339178813-Feb-10 2:45
Member 339178813-Feb-10 2:45 
AnswerRe: please help me i want to file send Pin
Saksida Bojan13-Feb-10 3:06
Saksida Bojan13-Feb-10 3:06 
GeneralRe: please help me i want to file send Pin
Member 339178813-Feb-10 4:35
Member 339178813-Feb-10 4:35 
GeneralRe: please help me i want to file send Pin
Saksida Bojan13-Feb-10 5:01
Saksida Bojan13-Feb-10 5:01 
GeneralRe: please help me i want to file send Pin
Member 339178814-Feb-10 20:12
Member 339178814-Feb-10 20:12 
Questioninvoice form design Pin
sudhir behera13-Feb-10 1:01
sudhir behera13-Feb-10 1:01 
AnswerRe: invoice form design Pin
Saksida Bojan13-Feb-10 1:18
Saksida Bojan13-Feb-10 1:18 
GeneralRe: invoice form design Pin
sudhir behera13-Feb-10 1:21
sudhir behera13-Feb-10 1:21 
GeneralRe: invoice form design Pin
Saksida Bojan13-Feb-10 1:29
Saksida Bojan13-Feb-10 1:29 
GeneralRe: invoice form design Pin
sudhir behera13-Feb-10 1:32
sudhir behera13-Feb-10 1:32 

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.