-
Notifications
You must be signed in to change notification settings - Fork 90
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
Samples used from “F# 3.0 Sample Pack” (http://fsharp3sample.codeplex.com/) at Codeplex OpenSource Community for non-commercial usage. All copyrights and authorship on materials this publication based on, is belongs to Microsoft corp. Copyright © 2006-2011 Microsoft Corporation, . All rights reserved. Copyright and autorship for materials in Nemerle language belongs to Nemerle Project Team. Copyright © 2008-2011 Nemerle Project Team. All rights reserved.