0

I am using sqlDatareader to read and assign variable value. The variable datatype is string.

string displayUnits = dr["DisplayUnits"].ToString(); // the variable value "DisplayUnitType.DUT_GENERAL"

Variable value is used to assign formatOptions.DisplayUnits.

formatOptions.DisplayUnits = displayUnits;

However, I am getting an error message cannot implicitly convert type string to Autodesk.Revit.BD.DisplayUnitType. I know I assigned a value to another type.

How do I casting and type conversions?

Dale K
  • 25,246
  • 15
  • 42
  • 71

1 Answers1

0

Indeed, you cannot implicitly convert a string to an enum.

You can explicitly convert a string to an enum in C#, as Chetan already pointed out.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17