C# TypeInfo IsSerializable
Description
TypeInfo IsSerializable
Gets a value indicating whether
the Type is serializable.
Syntax
TypeInfo.IsSerializable
has the following syntax.
public virtual bool IsSerializable { get; }
Example
The following example creates an instance of MyTestClass class, sets the [Serializable] attribute, and checks the IsSerializable property for true or false.
//w w w .j a v a2s . c om
using System;
namespace SystemType
{
public class MyClass
{
[Serializable] public class MyTestClass
{
}
public static void Main(string []args)
{
bool myBool = false;
MyTestClass myTestClassInstance = new MyTestClass();
Type myType = myTestClassInstance.GetType();
myBool = myType.IsSerializable;
Console.WriteLine("\nIs {0} serializable? {1}.", myType.FullName, myBool.ToString());
}
}
}
The code above generates the following result.