You can have the method that recieves the string parameter recieve the enum,
and that function can use the enum.ToString() to parse the argument as a
string:
public void Check( MyEnum x )
{
string s = x.ToString();
...
}
public void Submit()
{
Check( MyEnum.BooBoo );
}
Ron
"yanir" <yanir_r (AT) hotmail (DOT) com> wrote
Quote:
Hi
I have a function that get a string, but only of a few
specific values should be valid(e.g. the string can be
only one of the follows: "foo", "moo", "booboo") like an
enumarator that limits the integer range.
Is there any common technique to force, the developer who
call my function, to assign only those values, at compile
time and not at run time?(I know I can switch case
according to an enum but I rather to avoid it).
Thanks, Yanir |