C Sharp - Variables

Numbers

int a;

Declares an integer with a name of ‘a’. It must have a value.

int? b;

Introduced with C# 8.0

Declares an integer that can be null. This can be done with objects as well.

Strings

Checking for blanks

1
2
if (string.IsNullOrEmpty(code))
return null;

Array of Strings

1
String[] weekDays = new string[3] {"Sun", "Mon", "Tue", "Wed"};

References

Return to C Sharp [[home]] page