Hi Stefan, This is a defined part of the language, you can use it safely. It will never change.
Martin -----Ursprüngliche Nachricht----- Von: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED]] Im Auftrag von Stefan Holdermans Gesendet: Freitag, 14. Juni 2002 08:57 An: [EMAIL PROTECTED] Betreff: [ADVANCED-DOTNET] Evaluation of boolean expressions. I really like the way C# handles boolean expressions like: a && b and c || d. If a is false, b is not evaluated, since the expression cannot be satisfied anyway; if c is true, d is not evaluated. But -- is this just a Microsoft-specific implementation of the && and || operators? Or do the specifications demand all C# implementations to handle boolean expressions like this? E.g., is it safe to code: void foo(string bar) { if (bar != null && bar.Length > 3) { ... } else { ... } } or would a C# implementation be allowed to throw me a NullReferenceException if bar is a null reference? (VB6 would throw you an error, since it actually does always evaluate the second subexpression, indifferent from what the first subexpression evaluated to. One can argue that the second subexpression should always be evaluates since it may be a method that, besides returning a boolean, incorparates some side-effects... but arent't those side-effects bad practice anyway ;)?) --Stefan You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.