Showing posts with label serialization. Show all posts
Showing posts with label serialization. Show all posts

Thursday, July 22, 2010

Serializing Generic Types

There is no way currently of constraining a Generic type to ensure it is serializable at compile-time. However, there is a quick and easy way to check.


if (!typeof(T).IsSerializable)
{
throw new ArgumentException("type is not serializable");
}