I would like to clean my code and make it more simple. Now I've got a method which returns and int value.
private int ReturnMyValue(string line)
{
switch (line)
{
case "ST":
return 1;
case "KG":
return 2;
case "M":
return 3;
case "M2":
return 4;
(...)
}
}
Before that, I read an array of strings from a file, so it looks like this:
var myString = "";
var splittedString = myString.Split('|');
var iWantThatValue = ReturnMyValue(splitted[0]);
Is there a way to have an enum like this:
private enum Value
{
ST = 1,
KG = 2
}
and get rid of the method somehow ?
I want my iWantThatValue
to be 1 when splitted[0]
equals "ST".