Export (0) Print
Expand All
Expand Minimize

Type.IsMarshalByRefImpl Method

Implements the IsMarshalByRef property and determines whether the Type is marshaled by reference.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

protected virtual bool IsMarshalByRefImpl ()
protected boolean IsMarshalByRefImpl ()
protected function IsMarshalByRefImpl () : boolean
Not applicable.

Return Value

true if the Type is marshaled by reference; otherwise, false.

This method can be overridden by a derived class.

The following example determines whether the given type is marshaled by reference and displays the result.

using System;
using System.Reflection;
public class MyTypeDelegatorClass : TypeDelegator
{
    public string myElementType = null;
    private Type myType = null ; 
    public MyTypeDelegatorClass(Type myType) : base(myType)
    {
        this.myType = myType;
    }
    // Override IsMarshalByRefImpl.
    protected override bool IsMarshalByRefImpl()
    {
        // Determine whether the type is marshalled by reference.
        if(myType.IsMarshalByRef)
        { 
            myElementType = " marshalled by reference";
            return true;
        }
        return false;
    }
}
public class MyTypeDemoClass
{
    public static void Main()
    {
        try
        {
            MyTypeDelegatorClass myType;
            Console.WriteLine ("Determine whether MyContextBoundClass is marshalled by reference.");
            // Determine whether MyContextBoundClass type is marshalled by reference.
            myType = new MyTypeDelegatorClass(typeof(MyContextBoundClass));
            if( myType.IsMarshalByRef )
            {
                Console.WriteLine(typeof(MyContextBoundClass) + " is marshalled by reference.");
            }
            else
            {
                Console.WriteLine(typeof(MyContextBoundClass) + " is not marshalled by reference.");
            }

            // Determine whether int type is marshalled by reference.
            myType = new MyTypeDelegatorClass(typeof(int));
            Console.WriteLine ("\nDetermine whether int is marshalled by reference.");
            if( myType.IsMarshalByRef)
            {
                Console.WriteLine(typeof(int) + " is marshalled by reference.");
            }
            else
            {
                Console.WriteLine(typeof(int) + " is not marshalled by reference.");
            }
        }
        catch( Exception e )
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }
}
// This class is used to demonstrate the IsMarshalByRefImpl method.
public class MyContextBoundClass : ContextBoundObject
{
    public string myString = "This class is used to demonstrate members of the Type class.";
}

import System.*;
import System.Reflection.*;

public class MyTypeDelegatorClass extends TypeDelegator
{
    public String myElementType = null;
    private Type myType = null;

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

    // Override IsMarshalByRefImpl.
    protected boolean IsMarshalByRefImpl()
    {
        // Determine whether the type is marshalled by reference.
        if (myType.get_IsMarshalByRef()) {
            myElementType = " marshalled by reference";
            return true;
        }
        return false;
    } //IsMarshalByRefImpl
} //MyTypeDelegatorClass

public class MyTypeDemoClass
{
    public static void main(String[] args)
    {
        try {
            MyTypeDelegatorClass myType;
            Console.WriteLine("Determine whether MyContextBoundClass is" 
                + " marshalled by reference.");
            // Determine whether MyContextBoundClass type is marshalled
            // by reference.
            myType = new MyTypeDelegatorClass(MyContextBoundClass.
                class.ToType());
            if (myType.get_IsMarshalByRef()) {
                Console.WriteLine(MyContextBoundClass.class.ToType() 
                    + " is marshalled by reference.");
            }
            else {
                Console.WriteLine(MyContextBoundClass.class.ToType() 
                    + " is not marshalled by reference.");
            }
            // Determine whether int type is marshalled by reference.
            myType = new MyTypeDelegatorClass(int.class.ToType());
            Console.WriteLine("\nDetermine whether int is marshalled by" 
                + " reference.");
            if (myType.get_IsMarshalByRef()) {
                Console.WriteLine(int.class.ToType() 
                    + " is marshalled by reference.");
            }
            else {
                Console.WriteLine(int.class.ToType() 
                    + " is not marshalled by reference.");
            }
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception: {0}", e.get_Message());
        }
    } //main
} //MyTypeDemoClass

// This class is used to demonstrate the IsMarshalByRefImpl method.
public class MyContextBoundClass extends ContextBoundObject
{
    public String myString = "This class is used to demonstrate members" 
        + " of the Type class.";
} //MyContextBoundClass

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft