C# in A Nutshell - Code Listings - 5
C# in A Nutshell - Code Listings - 5
Syntax Basics
Type Basics
Numeric Types
// == and != test for equality and inequality of any type, but always return a bool value
// (unless overloaded otherwise). Value types typically have a very simple notion of equality:
int x = 1;
int y = 2;
int z = 1;
// The && and || operators test for and and or conditions. They are frequently used in
// conjunction with the ! operator, which expresses not:
Shortcircuiting
// The && and || operators short-circuit. This is essential in allowing expressions such as
// the following to run without throwing a NullReferenceException:
StringBuilder sb = null;
https://www.albahari.com/nutshell/E12-CH02.aspx 1/3
4/18/24, 1:15 AM C# in a Nutshell - Code Listings
// Same examples as before, but with & and | instead of && and ||.
// The results are identical, but without short-circuiting:
StringBuilder sb = null;
// The conditional operator (also called the ternary operator) has the form
// q ? a : b
// where if condition q is true, a is evaluated, else b is evaluated.
Arrays
Null Operators
Statements
Namespaces
C# 12
in a Nutshell
About the Book
Code Listings
C# 12 in a Nutshell
C# 10 in a Nutshell
C# 9.0 in a Nutshell
C# 8.0 in a Nutshell
C# 7.0 in a Nutshell
https://www.albahari.com/nutshell/E12-CH02.aspx 2/3
4/18/24, 1:15 AM C# in a Nutshell - Code Listings
Extras
Contact
https://www.albahari.com/nutshell/E12-CH02.aspx 3/3