Initialization of simple types in C#
Forums:
//"const" + type name for constants and
//"var" or type name for variables
//Int
int number = 42, otherNumber = 37;
const UInt64 maxInt64 = UInt64.MaxValue;
const int Mb = 1048576;
//Double
const double exp = 2.71828;
//Float
const float pi = 3.14f;
//String
const string greeting = "Hello";
//Multiline String
var text = @"this is some
multiline text";
//Bool
const bool sunIsStar = true;
var earthIsStar = false;
//Character "A"
const char charA = 'A';//'\x0041'; (char)65; '\u0041'
//Tuple (Int, String)
var one = Tuple.Create(1, "one");
- Log in to post comments