Type.IsValueTypeImpl メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Type.IsValueTypeImpl メソッドの意味・解説 

Type.IsValueTypeImpl メソッド

IsValueType プロパティ実装し、Type値型であり、クラスインターフェイスでないかどうか判断します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Protected Overridable Function
 IsValueTypeImpl As Boolean
protected virtual bool IsValueTypeImpl ()
protected:
virtual bool IsValueTypeImpl ()
protected boolean IsValueTypeImpl ()
protected function IsValueTypeImpl () : boolean

戻り値
Type値型である場合trueそれ以外場合false

解説解説

値型とは、ビット連続表される値のことです。値型は、クラスインターフェイスではありません。この値型は、一部プログラミング言語では "構造体" と呼ばれます列挙型 (Enum) は値型1 つです。

使用例使用例
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class MyTypeDelegator
   Inherits TypeDelegator
   Public myElementType As String
 = Nothing
   Private myType As Type = Nothing
   
   Public Sub New(myType
 As Type)
      MyBase.New(myType)
      Me.myType = myType
   End Sub 'New
   
   ' Override the IsValueTypeImpl() method of the Type class.
   Protected Overrides Function
 IsValueTypeImpl() As Boolean
      ' Determine whether the type is a value type.
      If myType.IsValueType Then
         myElementType = "value"
         Return True
      End If
      ' The type is not a value type.
      Return False
   End Function 'IsValueTypeImpl
End Class 'MyTypeDelegator

Public Class Type_IsValueTypeImpl

   Public Class MyClass1
   End Class 'MyClass1
   
   Public Shared Sub Main()
      Try
         Dim myInt As Integer
 = 0
         Dim myClass1 As New
 MyClass1()
         
         Dim myType As New
 MyTypeDelegator(myInt.GetType())
         Console.WriteLine(ControlChars.NewLine + "Determine whether
 a variable refers to a value type." + ControlChars.NewLine)
         
         ' Determine whether 'myType' is a value type.  
         If myType.IsValueType Then
            Console.WriteLine(ControlChars.NewLine + "'myInt' is
 a {0} type.", myType.myElementType)
         Else
            Console.WriteLine(ControlChars.NewLine + "'myInt' is
 not a value type.")
         End If 
         myType = New MyTypeDelegator(myClass1.GetType())
         
         ' Determine whether 'myType' is a value type.  
         If myType.IsValueType Then
            Console.WriteLine(ControlChars.NewLine + "'myClass1'
 is a {0} type.", myType.myElementType)
         Else
            Console.WriteLine(ControlChars.NewLine + "'myClass1'
 is not a value type.")
         End If 
      Catch e As Exception
         Console.WriteLine(ControlChars.NewLine + "The following
 exception is raised:" + e.Message.ToString())
      End Try
   End Sub 'Main
End Class 'Type_IsValueTypeImpl
using System;
using System.Reflection;

public class MyTypeDelegator : TypeDelegator
{
   public string myElementType = null;
   private Type myType = null ; 

   public MyTypeDelegator(Type myType) : base(myType)
   {
      this.myType = myType;
   }

   // Override 'IsValueTypeImpl()' method of 'Type' class.
   protected override bool IsValueTypeImpl()
   {
      // Determine whether the type is a value type.
      if(myType.IsValueType)
      {
         myElementType = "value";
         return true;
      }
      // The type is not value type.
      return false;
   }  
}
public class Type_IsValueTypeImpl 
{
   public class MyClass
   {
   }
   public static void Main()
   {
      try
      {
         int myInt = 0 ; 
         MyClass myClass = new MyClass ();

         MyTypeDelegator myType = new MyTypeDelegator(myInt.GetType());
         Console.WriteLine("\nCheck whether a variable refers to a value type.\n");
         
         // Determine whether 'myType' is a value type.  
         if( myType.IsValueType)
            Console.WriteLine("\n'myInt' is a {0} type.", myType.myElementType);
         else
            Console.WriteLine("\n'myInt' is not a value type.");

         myType = new MyTypeDelegator(myClass.GetType());

         // Determine whether 'myType' is a value type.  
         if( myType.IsValueType)
            Console.WriteLine("\n'myClass' is a {0} type.", myType.myElementType);
         else
            Console.WriteLine("\n'myClass' is not a value type.");

      }
      catch( Exception e )
      {
            Console.WriteLine("\nThe following exception is raised:" +e.Message);
      }
   }
}
using namespace System;
using namespace System::Reflection;
public ref class MyTypeDelegator: public
 TypeDelegator
{
public:
   String^ myElementType;

private:
   Type^ myType;

public:
   MyTypeDelegator( Type^ myType )
      : TypeDelegator( myType )
   {
      this->myType = myType;
   }


protected:

   // Override 'IsValueTypeImpl()' method of 'Type' class.
   virtual bool IsValueTypeImpl() override 
   {
      
      // Determine whether the type is a value type.
      if ( myType->IsValueType )
      {
         myElementType = "value";
         return true;
      }

      
      // The type is not value type.
      return false;
   }

};

public ref class MyClass{};

int main()
{
   try
   {
      int myInt = 0;
      MyClass^ myClass = gcnew MyClass;
      MyTypeDelegator^ myType = gcnew MyTypeDelegator( myInt.GetType() );
      Console::WriteLine( "\nCheck whether a variable refers to a value type.\n"
 );
      
      // Determine whether 'myType' is a value type.
      if ( myType->IsValueType )
            Console::WriteLine( "\n'myInt' is a {0} type.", myType->myElementType
 );
      else
            Console::WriteLine( "\n'myInt' is not a value type." );
      myType = gcnew MyTypeDelegator( myClass->GetType() );
      
      // Determine whether 'myType' is a value type.
      if ( myType->IsValueType )
            Console::WriteLine( "\n'myClass' is a {0} type.", myType->myElementType
 );
      else
            Console::WriteLine( "\n'myClass' is not a value type." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nThe following exception is raised: {0}", e->Message
 );
   }

}

import System.*;
import System.Reflection.*;
public class MyTypeDelegator extends TypeDelegator
{
    public String myElementType = null;
    private Type myType = null;

    public MyTypeDelegator(Type myType)
    {
        super(myType);
        this.myType = myType;
    } //MyTypeDelegator

    // Override 'IsValueTypeImpl()' method of 'Type' class.
    protected boolean IsValueTypeImpl()
    {
        // Determine whether the type is a value type.
        if (myType.get_IsValueType()) {
            myElementType = "value";
            return true;
        }
        // The type is not value type.
        return false;
    } //IsValueTypeImpl
} //MyTypeDelegator

public class Type_IsValueTypeImpl
{
    static public class
 MyClass
    {
    } //MyClass

    public static void main(String[]
 args)
    {
        try {
            int myInt = 0;
            MyClass myClass = new MyClass();

            MyTypeDelegator myType = new MyTypeDelegator(((System.
                Int32)myInt).GetType());
            Console.WriteLine("\nCheck whether a variable refers to" 
                + " a value type.\n");
            // Determine whether 'myType' is a value type.  
            if (myType.get_IsValueType()) {
                Console.WriteLine("\n'myInt' is a {0} type.",
                    myType.myElementType);
            }
            else {
                Console.WriteLine("\n'myInt' is not a value type.");
            }
            myType = new MyTypeDelegator(myClass.GetType());
            // Determine whether 'myType' is a value type.  
            if (myType.get_IsValueType()) {
                Console.WriteLine("\n'myClass' is a {0} type.",
                    myType.myElementType);
            }
            else {
                Console.WriteLine("\n'myClass' is not a value type.");
            }
        }
        catch (System.Exception e)
        {
            Console.WriteLine("\nThe following exception is raised:" 
                + e.get_Message());
        }
    } //main
} //Type_IsValueTypeImpl
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Type クラス
Type メンバ
System 名前空間
TypeAttributes
IsClass
IsInterface
ValueType
IsValueType


このページでは「.NET Framework クラス ライブラリ リファレンス」からType.IsValueTypeImpl メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からType.IsValueTypeImpl メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からType.IsValueTypeImpl メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Type.IsValueTypeImpl メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Type.IsValueTypeImpl メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS