Convertir un type String en Enum
2005-10-20 #code-snippets#csharp
enum EngineType {
unknow,
access,
db2,
mysql,
odbc,
oledb,
oracle,
postgre,
sqlserver
}
string cnxTypeString = "mysql";
EngineType cnxTypeEngine = EngineType.unknow;
if (Enum.IsDefined(typeof(EngineType), cnxTypeString)) {
cnxTypeEngine = (EngineType) Enum.Parse(typeof(EngineType), cnxTypeString, true);
}