Hi I am using enums converted to a string with a switch but it doesn’t work. It gives compilation error: Cannot implicitly convert type ‘userControl_commontop.UserType’ to ‘string’
The code is:
private void CommonTopChangesnew(string usertype)
{
switch (usertype.Trim().ToUpper())
{
case UserType.NORMAL :
hlkSAD.Enabled = false;
hlkMRTQuery.Enabled = false;
hlkReqViewer.Enabled = false;
hlkSendnotif.Enabled = false;
break;
case UserType.POWER :
hlkSAD.Enabled = false;
hlkReqViewer.Enabled = false;
hlkSendnotif.Enabled = false;
break;
}
}
enum UserType
{
NORMAL,
POWER,
ADMINISTRATOR
}
You could convert the userType parameter in to an enum value using this function:
as
and then you can call your switch statement as: