C# Test Code

int myNum = 377;
switch (myNum)
{
case 20:
Console.WriteLine("num is 1");
break;
case 377:
Console.WriteLine("Num is 2");
break;
default:
Console.WriteLine("default case");
break;
}
int [ ] intArray = new int [ ] { 232, 373, 326161, 8969869 };
{
string [ ] myArray = new string [ ] {"I", "learned", "to", "code", "thanks", "to", "you", "Grant"};
int arrayLength = intArray.Length;
string word = myArray [4];
Console.WriteLine(arrayLength.ToString());
Console.WriteLine(word);
}
int i = 20;
while (i < 100) {
Console.WriteLine("Value of i = "+ i.ToString());
i++;
}
bool trueOrFalse = true;
Console.WriteLine(trueOrFalse);
public void AddDouble (double A, double B) {
double result = A + B;
Console.WriteLine(result.ToString());
}
AddDouble(2333.444, 554.6566);
AddDouble(38585.387475, 476563.6578498396);
AddDouble(29587676.498653478, 4737683.888994);
public class MyCar
{
int topSpeed;
string color;
public MyCar (int passedTopSpeed, string passedColor) {
topSpeed = passedTopSpeed;
color = passedColor;
}
public int GetTopSpeed () {
return topSpeed;
}
public void PaintCar (string newColor) {
color = newColor;
}
}
MyCar toyota = new MyCar(89, "Red");
toyota.PaintCar("Green");
Console.WriteLine(toyota.GetTopSpeed().ToString());
string myName = "Grant";
try {
int myNum = Convert.ToInt16 (myName);
}
catch (Exception e) {
Console.WriteLine("Error: " + e.Message);
}