how can I get the string representation of an enumeration??

  • Thread starter Thread starter Green
  • Start date Start date
G

Green

Hi, All
I have an Enumeration SqlDbType.Int, I want to convert to
"SqlDbType.Int". How to do this, thanks very much!
 
The following code will show System.Data.SqlDbType.Int:

SqlDbType t = SqlDbType.Int;
string s = t.GetType().ToString() + "." + t.ToString();
MessageBox.Show(s);
 
Green said:
I have an Enumeration SqlDbType.Int, I want to convert to
"SqlDbType.Int". How to do this, thanks very much!

Hi. Use GetName():

string x = System.Enum.GetName(typeof(SqlDbType), SqlDbType.Int);

-- Alan
 
Back
Top