--- title: "Serialization (C++/CLI) | Microsoft Docs" ms.custom: "" ms.date: "11/04/2016" ms.reviewer: "" ms.suite: "" ms.technology: - "cpp-windows" ms.tgt_pltfrm: "" ms.topic: "article" dev_langs: - "C++" helpviewer_keywords: - "serialization [C++]" - "SerializableAttribute class, managed applications" - "NonSerializedAttribute class, managed applications" - "managed code [C++], serializing" - ".NET Framework [C++], serialization" - "serialization [C++], about serialization" ms.assetid: 869010ca-74e1-4989-b409-4643cdb94084 caps.latest.revision: 13 author: "mikeblome" ms.author: "mblome" manager: "ghogen" translation.priority.ht: - "cs-cz" - "de-de" - "es-es" - "fr-fr" - "it-it" - "ja-jp" - "ko-kr" - "pl-pl" - "pt-br" - "ru-ru" - "tr-tr" - "zh-cn" - "zh-tw" --- # Serialization (C++/CLI) Serialization (the process of storing the state of an object or member to a permanent medium) of managed classes (including individual fields or properties) is supported by the and classes. ## Remarks Apply the **SerializableAttribute** custom attribute to a managed class to serialize the entire class or apply only to specific fields or properties to serialize parts of the managed class. Use the **NonSerializedAttribute** custom attribute to exempt fields or properties of a managed class from being serialized. ## Example ### Description In the following example, the class `MyClass` (and the property `m_nCount`) is marked as serializable. However, the `m_nData` property is not serialized as indicated by the **NonSerialized** custom attribute: ### Code ``` // serialization_and_mcpp.cpp // compile with: /LD /clr using namespace System; [ Serializable ] public ref class MyClass { public: int m_nCount; private: [ NonSerialized ] int m_nData; }; ``` ### Comments Note that both attributes can be referenced using their "short name" (**Serializable** and **NonSerialized**). This is further explained in [Applying Attributes](/dotnet/standard/attributes/applying-attributes). ## See Also [.NET Programming with C++/CLI (Visual C++)](../dotnet/dotnet-programming-with-cpp-cli-visual-cpp.md)