A common misconception is that if the class has the [Serializable] attribute, it can be serialized. This may or may not be the case. If any one of the fields in the class cannot be serialized, the serialization of the class fails.
If you would like to programmatically determine if a class can probably be serialized, use the following code. The code determines if the class Employee can be serialized or not: