
Hi
I am trying to compare the option set value in my class. but I am getting this error "{"Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.IConvertible'."}." can any one please suggest to resolve this problem.please it's very urgent.
here is my code
if(new OptionSetValue(Convert.ToInt32(sa.Attributes["isr_typeofdegree"])).Value== new OptionSetValue(Convert.ToInt32(905080000)).Value)
{
//logic
}
*This post is locked for comments
I have the same question (0)You are trying to convert sa.Attributes["isr_typeofdegree"] into an int32 but this is not something that can be casted this way. isr_typeofdegree seems to be of type "OptionSetValue" and thus you want to use the Value of it to retrieve the int.
There's no need to create more wrappers around just the int.
Your code would be better off doing something like:
if(((OptionSetValue)sa.Attributes["isr_typeofdegree"]).Value == 905080000) {
//logic
}