Numbers, Precision, Casting, Doubles, and More [Pt 8]

Natural type and Explicit type

double a = 42.1; // natural type
float b = 38.2F; // explicit type
double c = checked(a + b);
Console.WriteLine(c);

decimal d = 42.1M; // explicit type
decimal e = 38.2M;
decimal f = d + e;
Console.WriteLine($"The answer is {f}");

Numbers, Integers, and Math [Pt 7]

Integer overflow and explicit casting

int a = 2100000000;
int b = 2100000000;

int c = a + b;
Console.WriteLine(c); // Output: -94967296

long d = a + b;
Console.WriteLine(d); // Output: -94967296

long e = (long)a + (long)b; // Explicit casting, type casting or explicit type conversion
Console.WriteLine(e); // Output: 4200000000

• Minimum value: -9,223,372,036,854,775,808 (approximately -9.2 quintillion)

• Maximum value: 9,223,372,036,854,775,807 (approximately 9.2 quintillion)

Searching Strings [Pt 6]

Replace

string greeting = $"hello {firstFriends} and {secondFriends}";
Console.WriteLine(greeting);

greeting = greeting.Replace("Ray", "Donna");
Console.WriteLine(greeting);

// Output:
// hello Nicole and Ray
// hello Nicole and Donna

The Basics of Strings! [Pt 5]

Interpolation and Concatenate in string