When trying to call this function in my code i get the error in the title. Also Operator \'+=\' cannot be applied to the operands of type \'int\' and \'T\'
p
I had a very similar problem. It is not exactly the problem asked here, but it could be a start point:
private T GetXValue(XElement xElem, string name)
{
try
{
object o = xElem.Element(name).Value;
return (T)Convert.ChangeType(o, typeof(T));
}
catch
{
return (T)Activator.CreateInstance(typeof(T), null);
}
}