For getting the option set value:
int value = ((OptionSetValue)entity["yourattributename"]).Value;
For getting the text:
String text = entity.FormattedValues["yourattributename"].ToString();
In the above code entity is the Entity object from which the optionset value/text to be retrieved. Please replace the attribute name with your case.