Runtime class and object in .net
2009-05-11 06:47
435 查看
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace BindingFlagsCS
{
class Program
{
static void Main(string[] args)
{
AssemblyName an = new AssemblyName();
an.Name = "Runtime assembly";
an.Version = new Version("1.0.0.0");
AppDomain ad = AppDomain.CurrentDomain;
AssemblyBuilder ab = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly);
ModuleBuilder mb = ab.DefineDynamicModule("Runtime", "Runtime.dll");
TypeBuilder tb = mb.DefineType("Joey", TypeAttributes.Public);
Type joey = tb.CreateType();
Console.WriteLine("Type's full name: "+joey.FullName);
foreach (MemberInfo mi in joey.GetMembers())
{
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name);
}
Console.Read();
}
}
}
VB.NET:
Imports System.Reflection
Imports System.Reflection.Emit
Module Module1
Sub Main()
Dim an As AssemblyName = New AssemblyName
an.Name = "Runtime assembly"
an.Version = New Version("1.0.0.0")
Dim ad As AppDomain = AppDomain.CurrentDomain
Dim ab As AssemblyBuilder = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly)
Dim mb As ModuleBuilder = ab.DefineDynamicModule("RunTime", "Runtime.dll")
Dim tb As TypeBuilder = mb.DefineType("Joey", TypeAttributes.Public)
Dim joey As Type = tb.CreateType
Console.WriteLine("Type's full name: " + joey.FullName)
For Each mi As MemberInfo In joey.GetMembers
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name)
Next
Console.Read()
End Sub
End Module
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace BindingFlagsCS
{
class Program
{
static void Main(string[] args)
{
AssemblyName an = new AssemblyName();
an.Name = "Runtime assembly";
an.Version = new Version("1.0.0.0");
AppDomain ad = AppDomain.CurrentDomain;
AssemblyBuilder ab = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly);
ModuleBuilder mb = ab.DefineDynamicModule("Runtime", "Runtime.dll");
TypeBuilder tb = mb.DefineType("Joey", TypeAttributes.Public);
Type joey = tb.CreateType();
Console.WriteLine("Type's full name: "+joey.FullName);
foreach (MemberInfo mi in joey.GetMembers())
{
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name);
}
Console.Read();
}
}
}
VB.NET:
Imports System.Reflection
Imports System.Reflection.Emit
Module Module1
Sub Main()
Dim an As AssemblyName = New AssemblyName
an.Name = "Runtime assembly"
an.Version = New Version("1.0.0.0")
Dim ad As AppDomain = AppDomain.CurrentDomain
Dim ab As AssemblyBuilder = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly)
Dim mb As ModuleBuilder = ab.DefineDynamicModule("RunTime", "Runtime.dll")
Dim tb As TypeBuilder = mb.DefineType("Joey", TypeAttributes.Public)
Dim joey As Type = tb.CreateType
Console.WriteLine("Type's full name: " + joey.FullName)
For Each mi As MemberInfo In joey.GetMembers
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name)
Next
Console.Read()
End Sub
End Module
相关文章推荐
- java.lang.Object in Java and System.Object class in C#
- An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET
- How to create Immutable Class and Object in Java - Tutorial Example
- Ambiguous method call. Both getClass () in Object and getClass () in Object match.
- Using CoCreateObjectDotNet to Access and Use .NET Assemblies in InstallScript
- Java - Why wait, notify and notifyAll is defined in Object Class and not on Thread class
- Where Are ClassWizard and WizardBar in Visual C++ .NET?[msdn]
- Redirect and Post JSON object in ASP.NET MVC
- The longest class name in Java and .NET Framework
- ASP.NET MVC - Redirect-and-Post-JSON-Object-in-ASP-NET-MVC
- In .net Class and Struct
- Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljav
- How to Determine if a file is a .Net assembly (in Delphi and C#)
- .NET Basics:difference between new and override in inherite
- WinForm C#: Simple Runtime Control ReSizing and Dragging & Moving Class
- .NET Versioning and Multi-Targeting - .NET 4.5 is an in-place upgrade to .NET 4.0
- Gene Expression Programming (GEP) in C# and .NET
- Add COM and ActiveX Support in .NET Compact Framework Using Odyssey Software CFCOM
- Fast Pixel Operations in .NET (With and Without unsafe)
- HikariCP 脑火Failed to obtain JDBC Connection: You need to run the CLI build and you need target/classes in your classpath to run.