发布于 2015-04-25 14:57:41 | 123 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

.NET Framework

.NET 是 Microsoft XML Web services 平台。你可以理解为.NET Framework ,XML Web services 允许应用程序通过 Internet 进行通讯和共享数据,而不管所采用的是哪种操作系统、设备或编程语言。Microsoft .NET 平台提供创建 XML Web services 并将这些服务集成在一起之所需。对个人用户的好处是无缝的、吸引人的体验。


示例代码:

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string basepath = System.AppDomain.CurrentDomain.BaseDirectory.Replace(@"\",@"");
Assembly asm = Assembly.LoadFrom(basepath+@"MyLib.dll");
//MyClass m = new MyClass(1, 2);
Type type = asm.GetType(@"MyLib.CT");
Type t = typeof(MyClass);
object[] parm = new object[2];
parm[0]=1;
parm[1]=2;
object obj = Activator.CreateInstance(t, parm);
object obj1 = Activator.CreateInstance(type, parm);
MethodInfo mth = t.GetMethod("sum");
MethodInfo mth1 = type.GetMethod("sum");
int i=(int) mth.Invoke(obj,null);
int j = (int)mth1.Invoke(obj1, null);
Console.WriteLine(j);
Console.ReadKey();
}
}
class MyClass
{
int x;
int y;
public MyClass(int i, int j)
{
x = i;
y = j;
}
public int sum()
{
return x + y;
}
public bool IsBetween(int i)
{
if (x < i && i < y) return true;
else return false;
}
public void Set(int a, int b)
{
x = a;
y = b;
}
public void Set(double a, double b)
{
x = (int)a;
y = (int)b;
}
public void Show()
{
Console.WriteLine("x:{0},y:{1}", x, y);
}
}
}


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务