Type.IsSerializable 속성

Type의 serialization 가능 여부를 나타내는 값을 가져옵니다.

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public ReadOnly Property IsSerializable As Boolean
‘사용 방법
Dim instance As Type
Dim value As Boolean

value = instance.IsSerializable
public bool IsSerializable { get; }
public:
virtual property bool IsSerializable {
    bool get () sealed;
}
/** @property */
public final boolean get_IsSerializable ()
public final function get IsSerializable () : boolean

속성 값

Type을 serialize할 수 있으면 true이고, 그렇지 않으면 false입니다.

설명

현재 Type이 생성된 제네릭 형식을 나타내는 경우 이 속성은 형식이 생성된 제네릭 형식 정의에 적용됩니다. 예를 들어, 현재 TypeMyGenericType<int>(Visual Basic의 경우 MyGenericType(Of Integer))을 나타내는 경우 이 속성의 값은 MyGenericType<T>에 의해 결정됩니다.

현재 Type이 제네릭 형식 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내는 경우 이 속성은 항상 false를 반환합니다.

예제

다음 예제에서는 MyTestClass 클래스의 인스턴스를 만들고 [Serializable] 특성을 설정하며 IsSerializable 속성이 true 또는 false인지 확인합니다.

Imports System
Imports Microsoft.VisualBasic
Namespace SystemType
    Public Class [MyClass]
        ' Declare a public class with the [Serializable] attribute.
        <Serializable()> Public Class MyTestClass
        End Class 'MyTestClass
        Public Overloads Shared Sub Main()
            Try
                Dim myBool As Boolean = False
                Dim myTestClassInstance As New MyTestClass()
                ' Get the type of myTestClassInstance.
                Dim myType As Type = myTestClassInstance.GetType()
                ' Get the IsSerializable property of myTestClassInstance.
                myBool = myType.IsSerializable
                Console.WriteLine(ControlChars.Cr + "Is {0} serializable? {1}.", myType.FullName, myBool.ToString())
            Catch e As Exception
                Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}", e.Message.ToString())
            End Try
        End Sub 'Main
    End Class '[MyClass]
End Namespace 'SystemType
using System;
namespace SystemType
{
    public class MyClass
    {
        // Declare a public class with the [Serializable] attribute.
        [Serializable] public class MyTestClass 
        {
        }
        public static void Main(string []args)
        {
            try
            {
                bool myBool = false;
                MyTestClass myTestClassInstance = new MyTestClass();
                // Get the type of myTestClassInstance.
                Type myType = myTestClassInstance.GetType();
                // Get the IsSerializable property of myTestClassInstance.
                myBool = myType.IsSerializable;
                Console.WriteLine("\nIs {0} serializable? {1}.", myType.FullName, myBool.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("\nAn exception occurred: {0}", e.Message);
            }
        }
    }
}
using namespace System;
public ref class MyClass
{
public:

   // Declare a public class with the [Serializable] attribute.

   [Serializable]
   ref class MyTestClass{};


};

int main()
{
   try
   {
      bool myBool = false;
      MyClass::MyTestClass^ myTestClassInstance = gcnew MyClass::MyTestClass;
      
      // Get the type of myTestClassInstance.
      Type^ myType = myTestClassInstance->GetType();
      
      // Get the IsSerializable property of myTestClassInstance.
      myBool = myType->IsSerializable;
      Console::WriteLine( "\nIs {0} serializable? {1}.", myType->FullName, myBool );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nAn exception occurred: {0}", e->Message );
   }

}
package SystemType;

import System.*;

public class MyClass
{
    // Declare a public class with the [Serializable] attribute.
    /** @attribute Serializable()
     */
    public static class MyTestClass
    {
    } //MyTestClass

    public static void main(String[] args)
    {
        try {
            boolean myBool = false;
            MyTestClass myTestClassInstance = new MyTestClass();

            // Get the type of myTestClassInstance.
            Type myType = myTestClassInstance.GetType();

            // Get the IsSerializable property of myTestClassInstance.
            myBool = myType.get_IsSerializable();
            Console.WriteLine("\nIs {0} serializable? {1}.",
                myType.get_FullName(), System.Convert.ToString(myBool));
        }
        catch (System.Exception e) {
            Console.WriteLine("\nAn exception occurred: {0}", e.get_Message());
        }
    } //main
} //MyClass

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Type 클래스
Type 멤버
System 네임스페이스
TypeAttributes
ISerializable