C# Type Missing

In this chapter you will learn:

  1. Get to know Type.Missing
  2. Syntax for Type.Missing
  3. Example - Type.Missing

Description

Type Missing represents a missing value in the Type information. This field is read-only.

Syntax

Type.Missing has the following syntax.


public static readonly Object Missing

Example

The following code example shows the use of the Missing field to invoke a method with its default arguments.


using System;/*from  ww  w  .j  a  v a2s .  c om*/
using System.Reflection;
using System.CodeDom.Compiler;

class Example
{
    public static void Main()
    {
        Type t = typeof(System.String);
        BindingFlags bf = BindingFlags.Public | BindingFlags.Instance |
            BindingFlags.InvokeMethod | BindingFlags.OptionalParamBinding;

        t.InvokeMember("MyMethod", bf, null, o, new object[] {10, 55.3, 12});
        t.InvokeMember("MyMethod", bf, null, o, new object[] {10, 1.3, Type.Missing});
        t.InvokeMember("MyMethod", bf, null, o, new object[] {10, Type.Missing, Type.Missing});
    }
}

Next chapter...

What you will learn in the next chapter:

  1. Get to know Type.Assembly
  2. Syntax for Type.Assembly
  3. Example - Type.Assembly