C# Type IsMarshalByRefImpl

Description

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

Syntax

Type.IsMarshalByRefImpl has the following syntax.


protected virtual bool IsMarshalByRefImpl()

Returns

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

Example

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


//from   w  ww  . j ava 2s. c o m
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;
    }
    protected override bool IsMarshalByRefImpl()
    {
        if(myType.IsMarshalByRef)
        { 
            myElementType = " marshalled by reference";
            return true;
        }
        return false;
    }
}
public class MyTypeDemoClass
{
    public static void Main()
    {
       MyTypeDelegatorClass myType;
       Console.WriteLine ("Determine whether MyContextBoundClass is marshalled by reference.");
       myType = new MyTypeDelegatorClass(typeof(MyContextBoundClass));
       Console.WriteLine(myType.IsMarshalByRef);
    }
}
public class MyContextBoundClass : ContextBoundObject
{
    public string myString = "This class is used to demonstrate members of the Type class.";
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version