-
Notifications
You must be signed in to change notification settings - Fork 89
typeof operator extended
CodingUnit edited this page Nov 30, 2011
·
2 revisions
-
Category: Data Types
-
Description: Demostrate how to use typedefof operator to create generic type.
-
Code:
using System;
using System.Console;
using System.Collections.Generic;
def SampleTypeof2()
{
def intType = typeof(int);
def listType = typeof(List[_]);
def listIntType = listType.MakeGenericType(intType);
WriteLine("make a List type using typeof operator.");
WriteLine($"the newly created type`s full name is $(listIntType.FullName)");
}
SampleTypeof2()
- Execution Result:
make a List type using typeof operator. the newly created
type`s full name is System.Collections.Generic.List`1[System.Int32,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089](System.Int32,_mscorlib,_Version=4.0.0.0,_Culture=neutral,_PublicKeyToken=b77a5c561934e089)
[Copyright ©](Terms of use, legal notice)