Click here to Skip to main content
15,915,048 members
Home / Discussions / C#
   

C#

 
GeneralRe: Downloading files from FTP using C#.Net 1.1 Pin
N a v a n e e t h20-Feb-08 19:54
N a v a n e e t h20-Feb-08 19:54 
Questionfrozen column in Listview ? Pin
Xmen Real 20-Feb-08 18:26
professional Xmen Real 20-Feb-08 18:26 
AnswerRe: frozen column in Listview ? Pin
Dave Kreskowiak21-Feb-08 5:10
mveDave Kreskowiak21-Feb-08 5:10 
Generalwhy use | instead of || and same with & and && Pin
Xmen Real 20-Feb-08 18:06
professional Xmen Real 20-Feb-08 18:06 
GeneralRe: why use | instead of || and same with & and && Pin
mav.northwind20-Feb-08 19:27
mav.northwind20-Feb-08 19:27 
GeneralRe: why use | instead of || and same with & and && Pin
darkelv20-Feb-08 19:34
darkelv20-Feb-08 19:34 
GeneralRe: why use | instead of || and same with & and && Pin
Xmen Real 21-Feb-08 2:50
professional Xmen Real 21-Feb-08 2:50 
GeneralRe: why use | instead of || and same with & and && Pin
darkelv21-Feb-08 3:16
darkelv21-Feb-08 3:16 
Well, just use them as what they are meant for.

| and & for bitwise operation, much like + and /.

|| and && for logic operation, to make condition decision, or to get a true/false value, generally.

Most of the time, the result is the same, but the process where the result is resolved is different. Logic operation will be short-circuited by compiler, and I believe it is faster to be execute by CPU (correct me if I am wrong), because they are basically compare and jump operations.

If you use the bitwise operators instead of the logic operators, each and every one of the bitwise operators are to be evaluated, and under some situation, you may not get the same outcome:

obj= null;

a) if(obj != null && obj.ToString().Length > 0)
b) if(obj != null & obj.ToString().Length > 0)

Case b) will throw an exception because all of the statements in the if have to be evaluated.
GeneralRe: why use | instead of || and same with & and && Pin
John Oxley20-Feb-08 23:39
John Oxley20-Feb-08 23:39 
GeneralRe: why use | instead of || and same with & and && Pin
Xmen Real 21-Feb-08 2:37
professional Xmen Real 21-Feb-08 2:37 
GeneralRe: why use | instead of || and same with & and && Pin
Dan Neely21-Feb-08 2:59
Dan Neely21-Feb-08 2:59 
GeneralRe: why use | instead of || and same with & and && Pin
John Oxley21-Feb-08 4:46
John Oxley21-Feb-08 4:46 
GeneralRe: why use | instead of || and same with & and && Pin
Xmen Real 21-Feb-08 5:04
professional Xmen Real 21-Feb-08 5:04 
GeneralRe: why use | instead of || and same with & and && Pin
PIEBALDconsult21-Feb-08 5:51
mvePIEBALDconsult21-Feb-08 5:51 
GeneralCompletely OT: why use | instead of || and same with & and && Pin
John Oxley21-Feb-08 9:46
John Oxley21-Feb-08 9:46 
GeneralRe: Completely OT: why use | instead of || and same with & and && Pin
PIEBALDconsult21-Feb-08 12:09
mvePIEBALDconsult21-Feb-08 12:09 
QuestionProblem with faxcomlib.dll while sending pdf file as fax thru c#.net application Pin
saikiran20-Feb-08 17:44
saikiran20-Feb-08 17:44 
QuestionGUI items disabled? Pin
rakanishuu20-Feb-08 17:35
rakanishuu20-Feb-08 17:35 
AnswerRe: GUI items disabled? Pin
Vikram A Punathambekar20-Feb-08 17:44
Vikram A Punathambekar20-Feb-08 17:44 
GeneralRe: GUI items disabled? [modified] Pin
rakanishuu20-Feb-08 18:05
rakanishuu20-Feb-08 18:05 
GeneralTyped factories in C#3 Pin
Roger Alsing20-Feb-08 15:33
Roger Alsing20-Feb-08 15:33 
GeneralAccessing a object created in Form1 trough Form2 Pin
Stigern2k34k20-Feb-08 14:47
Stigern2k34k20-Feb-08 14:47 
GeneralRe: Accessing a object created in Form1 trough Form2 Pin
Pete O'Hanlon21-Feb-08 2:51
mvePete O'Hanlon21-Feb-08 2:51 
GeneralBitwise and, or, xor with doubles. Pin
PhilDanger20-Feb-08 13:44
PhilDanger20-Feb-08 13:44 
GeneralRe: Bitwise and, or, xor with doubles. Pin
Christian Graus20-Feb-08 13:53
protectorChristian Graus20-Feb-08 13:53 

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.