Suppose I want to create a new exception when calling a generic method with a type that does not have a required attribute. Is there a .NET exception that is suitable for this situation or, more likely, a suitable ancestor for a custom exception?
For instance:
public static class ClassA { public static T DoSomething<T>(string p) { Type returnType = typeof(T); object[] typeAttributes = returnType.GetCustomAttributes(typeof(SerializableAttribute), true); if ((typeAttributes == null) || (typeAttributes.Length == 0)) {
Thanks.
source share