I'm not quite sure if i understand you right.
if you want to safely convert a string to int see
int result;
bool wasConverted;
wasConverted = int.TryParse(test,out result)
For more generic conversion ahve a look at the ConvertClass.
For Example Convert.ChangeType but there you would have to handle exceptions your own way.
public object SafeConvertChangeType(object value,Type targetType)
{
object result ;
try {
result = Convert.ChangeType(value, targetType);
}
catch (FormatException)
catch (InvalidCastException) {
result = null;
}
return result;
}
you can that call the method this was:
var result = SafeConvertChangeType("Foo",typeof(int32));
You may also have a loot at this post: Test if Convert.ChangeType will work between two types. It points out that there is no "ConversionCheck" Api. So I assumed you would need that exception catch