Click here to Skip to main content
15,895,667 members
Home / Discussions / C#
   

C#

 
GeneralRe: A suggestion Pin
TNCaver9-Aug-10 6:48
TNCaver9-Aug-10 6:48 
GeneralRe: A suggestion Pin
Luc Pattyn9-Aug-10 6:56
sitebuilderLuc Pattyn9-Aug-10 6:56 
GeneralRe: A suggestion Pin
Kenneth Kasajian9-Aug-10 9:13
Kenneth Kasajian9-Aug-10 9:13 
GeneralRe: A suggestion Pin
Jonathan C Dickinson9-Aug-10 21:44
Jonathan C Dickinson9-Aug-10 21:44 
GeneralRe: A suggestion Pin
Richard MacCutchan9-Aug-10 22:03
mveRichard MacCutchan9-Aug-10 22:03 
GeneralRe: A suggestion Pin
Jonathan C Dickinson10-Aug-10 0:11
Jonathan C Dickinson10-Aug-10 0:11 
GeneralRe: A suggestion Pin
Richard MacCutchan10-Aug-10 0:43
mveRichard MacCutchan10-Aug-10 0:43 
GeneralRe: A suggestion Pin
Jonathan C Dickinson10-Aug-10 1:17
Jonathan C Dickinson10-Aug-10 1:17 
Hurm... The example doesn't need a == operator because it is demonstrating what is possible when a = and a == are distinct. With == around; = becomes more versatile. Because = is more versatile the example I gave is possible.

If there was only = (and no ==) the example I gave simply wouldn't work (you would get an warning saying that a boolean is never null). I think the mathematical term for this kind of 'proof' is proof by contradiction.

The compiler would recognize != as the not equals operator, BUT it would recognize the = as identity equality and not assignment. Thus the AST would look (where the VB-route is taken) something like this:

WHILESTMT(BOOLEXPR(BOOLEXPR("line", Operator.IdentityEquality, "reader.ReadLine"), Operator.IdentityInequality, NULL))

As opposed to (and why my example works):

WHILESTMT(BOOLEXPR(BOOLEXPR("line", Operator.Assign, "reader.ReadLine"), Operator.IdentityInequality, NULL))

More simply, the following expression results in a boolean type (and boolean value) in VB:

a = b

In C# is results in the type of 'a' (and the value contained by 'a'). Which is why these statements are possible:

int0 = int1 = int2 = int3 = int4 = 0; // Set all to 0.
He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chineese Proverb]

Jonathan C Dickinson (C# Software Engineer)

GeneralRe: A suggestion Pin
Richard MacCutchan10-Aug-10 1:48
mveRichard MacCutchan10-Aug-10 1:48 
GeneralRe: A suggestion Pin
Jonathan C Dickinson10-Aug-10 21:25
Jonathan C Dickinson10-Aug-10 21:25 
GeneralRe: A suggestion Pin
Keith Barrow7-Aug-10 5:13
professionalKeith Barrow7-Aug-10 5:13 
GeneralRe: A suggestion Pin
Richard MacCutchan7-Aug-10 7:12
mveRichard MacCutchan7-Aug-10 7:12 
GeneralRe: A suggestion [modified] Pin
PIEBALDconsult7-Aug-10 16:58
mvePIEBALDconsult7-Aug-10 16:58 
AnswerRe: A suggestion Pin
Luc Pattyn7-Aug-10 17:01
sitebuilderLuc Pattyn7-Aug-10 17:01 
GeneralRe: A suggestion Pin
Richard MacCutchan7-Aug-10 21:23
mveRichard MacCutchan7-Aug-10 21:23 
GeneralRe: A suggestion Pin
Jonathan C Dickinson9-Aug-10 21:40
Jonathan C Dickinson9-Aug-10 21:40 
GeneralRe: A suggestion Pin
Stefan_Lang11-Aug-10 5:13
Stefan_Lang11-Aug-10 5:13 
GeneralRe: A suggestion Pin
Richard MacCutchan11-Aug-10 7:31
mveRichard MacCutchan11-Aug-10 7:31 
GeneralRe: A suggestion Pin
Stefan_Lang11-Aug-10 23:02
Stefan_Lang11-Aug-10 23:02 
GeneralRe: A suggestion Pin
Richard MacCutchan12-Aug-10 1:30
mveRichard MacCutchan12-Aug-10 1:30 
AnswerRe: Cannot implicitly convert type 'object' to 'bool' PinPopular
Orjan Westin7-Aug-10 9:06
professionalOrjan Westin7-Aug-10 9:06 
GeneralRe: Cannot implicitly convert type 'object' to 'bool' PinPopular
Richard MacCutchan7-Aug-10 11:23
mveRichard MacCutchan7-Aug-10 11:23 
GeneralRe: Cannot implicitly convert type 'object' to 'bool' Pin
Orjan Westin7-Aug-10 12:12
professionalOrjan Westin7-Aug-10 12:12 
GeneralRe: Cannot implicitly convert type 'object' to 'bool' Pin
Richard MacCutchan7-Aug-10 21:19
mveRichard MacCutchan7-Aug-10 21:19 
GeneralRe: Cannot implicitly convert type 'object' to 'bool' Pin
ErrolErrol9-Aug-10 7:59
ErrolErrol9-Aug-10 7:59 

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.