Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass<T> where T : //[is serializable/has the serializable attribute]
- public void Initialize<T>(T obj)
- {
- object[] attributes = obj.GetType().GetCustomAttributes(typeof(SerializableAttribute));
- if(attributes == null || attributes.Length == 0)
- throw new InvalidOperationException("The provided object is not serializable");
- }
Add Comment
Please, Sign In to add comment