Im still in the mist of learning to program, very much lost in that mist actually. could someone help me please to implement this correctly, below is my code, bascially I have a method that takes in a value, tests that value within a switch.
Im jus very confused about how to catch the ArgumentOutOfRangeException correctly :S
public string InTheBox(int x)
{
try
{
//switch statment to lookup log ID
switch (x)
{
case 0:
return "Outter";
case 1:
return "Inner";
case 2:
return "Border";
default:
throw new ArgumentOutOfRangeException("Unknown value");
}
}
catch (ArgumentOutOfRangeException)
{
throw new ArgumentOutOfRangeException("Unknown value");
}
}
If someone could please explaing to me the cleanest way to catch these exceptions. Thank you!
Why do you have the try catch block at all? You can simply have