I have a enum like this.
public enum eTypeVar
{
Int,
Char,
Float
};
and I want to convert it to type , to do something like this:
eTypeVar type=eTypeVar .Int;
string str= eTypeVar.ToString .ToLower();
(str as type) a=1;
How would I do it?
I think what you need is:
You cannot convert a variable into a type for another variable declaration. You should rethink your design. Anyway it doesn’t make sence what you are doing. If you know that you want to use a int, why not declare it:If you want to have dynamic code for some reasons you could use Reflection and a generic method.
Then you can construct the method at runtime using reflection and invoke it. But at this time i think you need more basics of C# to work with this features.