The below code throws an exception when executing this line (i.e. something.Add(name)).
I want to catch the actual exception when executing this. I mean I don’t want to use catch(Exception ex) instead of that I want to know what is the correct exception thrown here.
try
{
dynamic name= "test";
var something = new List<decimal>();
something.Add(name);
}
catch(Exception ex)
{
throw ex;
}
Thanks in advance.
Not sure why you’re trying to cast a string to a decimal, but ok… The answer is Microsoft.System.CSharp.RuntimeBinder.RuntimeBinderException.
Source: Actually running the code. 🙂