I have a new project where I am adding some important string manupulation extensions.
I am trying to add a dynamic conversion extension as well.
As of now, I have done this
public static T To<T>(dynamic value) =>
value.Equals(DBNull.Value) ? default(T) : Convert.ChangeType(value, typeof(T));
But still while converting int, if we pass null value, error is occured.
How can I handle the error here?
New contributor
DeveNymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.