At runtime, I get the following error
"Object must implement IConvertible"
calling function
lboxBuildingType.SelectedIndex = pharse.returning<int>xdoc.Root.Element("BuildingTypeIndex").Value);
public static T returning<T>(object o)
{
Tuple<bool, T, object> tmp;
switch (Type.GetTypeCode(typeof(T)))
{
case TypeCode.Int32:
tmp= (Tuple<bool,T,object>)Convert.ChangeType(I(o.ToString())), typeof(T));
break;
}
}
private static Tuple<bool, Int32, Object> I(object o)
{
int i;
bool b;
Int32.TryParse(o.ToString(), out i);
b = (i == 0);
return new Tuple<bool, Int32, object>(b, i, o);
}
The purpose of the code is to convey and create tuple<Bool,T,object>
that willtuple<true, 15, "15">
Errors where I marked them with an error //
source
share