
.NET
xyjnufop
这个作者很懒,什么都没留下…
展开
-
How to: Execute Expression Trees
This topic shows you how to execute an expression tree. Executing an expression tree may return a value, or it may just perform an action such as calling a method.Only expression trees that repres转载 2009-09-19 21:14:00 · 540 阅读 · 0 评论 -
程序设计、分析一点良好的习惯
1.时间。(编译时、运行时) 代码的执行什么时候确定,比如 虚函数的执行在运行时,确定,而一般的成员方法,代码地址在编译时便可以确定2.地点(堆,栈,托管堆) 数据 在那里分配,在堆、栈、托管堆3.编译器帮我做了什么,我有做了什么。 每当写程序或者读程序。都尽量照上面几条去思考。。。原创 2009-09-17 22:00:00 · 339 阅读 · 0 评论 -
The pointer in C++ /CLI
C++ /CLI 中的指针有好几种1.最终句柄 tracking handle2.内部指针 interior pointer3.固定指针 pinning pointer4.这条也应该加上 ISO-C++ pointer tracking handle Pointer^ p=gcnew Point;array^ a=gcnew array(3)arra原创 2009-09-16 22:43:00 · 458 阅读 · 0 评论 -
头大的互操作
与COM 互操作tlbimp *.dll 导出一个程序集,这个程序集 包含调用COM组件的借口 C++ Interop原创 2009-09-15 21:40:00 · 336 阅读 · 0 评论 -
怎么不生成 .LIB文件
用VS创建了个Win32空的项目,要做一个dll,一切完了之后发现只生成了dll,没有生成lib,搜了半天才找到,原来要加入.deff的模块定义文件(包含到处函数的东东),加上之后,就生成.lib了原创 2009-09-16 14:51:00 · 1237 阅读 · 0 评论 -
几个表达式树
-aa + b * 2Math.Sin(x) + Math.Cos(y)new StringBuilder(“Hello”)new int[] { a, b, a + b}的表达式树 如下 但是下面的几个这么画呢?? a[i – 1] * ia.Length > b | b >= 0(高难度)new System.Windows.Point()原创 2009-09-13 21:33:00 · 376 阅读 · 0 评论 -
Windows how to exec programme which implemented with .net language
1.You write source code in C#. 2.You then compile it using the C# compiler (csc.exe) into an EXE. 3.The C# compiler outputs the MSIL code and a manifest into a read-only part of the EXE that has a sta转载 2009-09-09 21:07:00 · 278 阅读 · 0 评论 -
About Multi-Thread
把遇到过的对.Net线程的一些问题和误解集中起来和大家分享,也希望大家能一起补充,热烈欢迎讨论目录 基础篇 怎样创建一个线程 受托管的线程与 Windows线程 前台线程与后台线程 名为BeginXXX和EndXXX的方法是做什么用的 异步和多线程有什么关联 WinForm多线程编程篇 我的多线程WinForm程序老是抛出Invali转载 2009-07-06 20:54:00 · 468 阅读 · 0 评论 -
Which Expression trees can compiled into executed code
Only those expression trees that represent functions, namely Expression(Of (TDelegate>)>) and its parent type LambdaExpression, can be compiled into executable code. To execute other types of expressi原创 2009-09-19 21:04:00 · 416 阅读 · 0 评论 -
表达式树计算
Only expression trees that represent lambda expressions can be executed. Expression trees that represent lambda expressions are of type LambdaExpression or Expression)>). To execute these expression t原创 2009-09-23 09:04:00 · 636 阅读 · 0 评论 -
Get 与 Post
一、 在Form里面,可以使用post也可以使用get。它们都是method的合法取值。但是,post和get方法在使用上至少有两点不同: 1、Get方法通过URL请求来传递用户的输入。Post方法通过另外的形式。 2、Get方式的提交你需要用Request.QueryString来取得变量的值,而Post方式提交时,你必须通过Request.Form来访问提交的内容。 提示 通过get方法提交转载 2009-11-18 23:17:00 · 521 阅读 · 0 评论 -
asp.net客户端脚本调用页面方法
第一步:将某个页面的方法 有 webmethod attribute; [WebMethod] //只能是 public static 的方法 public static DateTime GetCurrentTime() { return DateTime.UtcNow; } 第二步: 页面有一个ScriptManager 设置它原创 2009-11-14 10:27:00 · 509 阅读 · 0 评论 -
Nunit 二
首先每个测试用列之间应该是独立的。不应该有任何的依赖关系。所以每个测试用列的数据都是独立的。 但是会存在这么一种情况。多个测试用列会使用同一组数据。这是这么办,难道要在每个测试用中都初始化 这一组数据吗,这样明显违反了DRY的原则。程序员都是偷懒的。那么 这时 Setup attribute开始有用处了。当某个方法 有这个attribute时 。在每个测试原创 2009-10-23 08:12:00 · 468 阅读 · 0 评论 -
Nunit一
keep the bar green to keep the code clean单元测试不是证明代码是对的,而是证明代码没有错简单使用方法被测试类 MathCompute.cs public class MathCompute { public int Largest(int[] array) {原创 2009-10-22 23:33:00 · 358 阅读 · 0 评论 -
C#泛型机制不支持在除方法外的其他成员
想写个泛型 property ,发现不支持 • C#泛型机制只支持“在方法声明上包含类型参数”——即泛型方法• C#泛型机制不支持在除方法外的其他成员(包括属性、事件、索引器、构造器、析构器)的声明上包含类 型参数,但这些成员本身可以包含在泛型类型中,并使用泛型类型的类型参数• 泛型方法既可以包含在泛型类型中,也可以包含在非泛型类型中原创 2009-09-22 10:31:00 · 336 阅读 · 0 评论 -
How to: Use Expression Trees to Build Dynamic Queries
This topic describes how to use expression trees to create dynamic LINQ queries. Dynamic queries are useful when the specifics of a query are not known at compile time. For example, an application m转载 2009-09-19 22:47:00 · 520 阅读 · 0 评论 -
一种常用的产生表达式的方式
static bool GetStringLength( string str) { Expression> exp = ss => ss.Contains("a"); return exp.Compile()(str); }原创 2009-09-22 23:53:00 · 363 阅读 · 0 评论 -
中序遍历 表达式树
看到园子的很多大牛最近 表达式树 这一快弄的挺热闹,我也来照葫芦画瓢一下数据结构虽然不好,但是这点底子还是有的............... 中序遍历表达式树 static String MidTraversalExpressionTress(Expression expressTree) { ConstantExpr原创 2009-09-22 00:11:00 · 1419 阅读 · 0 评论 -
元编程技术和动态编译
什么是元编程?运行时动态创建类型的功能称为元编程。(这个是.NET环境编程全景中的定义) 从学习UML就知道meta-的重要性了,再后来了解到MOF(MetaObjectFacility)就更加着迷这个Meta-。Meta- 在...之中... 对于想真正了解一个Framework,了解它的Meta东西是十分重要的。不管任何一个Framework,肯定存在着它自己的Meta转载 2009-09-06 16:00:00 · 395 阅读 · 0 评论 -
create enum type dynamically(in runtime)
MSDN上的列子,注意动态创建的顺序,Domain->assembley->module->enum 这个过程,如果我要动态建class是不是也是这个步骤? // Get the current application domain for the current thread. AppDomain currentDomain = Ap原创 2009-09-06 15:15:00 · 465 阅读 · 0 评论 -
反射动态调用
class Love { public int field1; private string _name; public Love() { } public string Name { get转载 2009-09-05 21:08:00 · 303 阅读 · 0 评论 -
Designer
这两天搞 表单设计器,用微软的Designer那一套,有很多类刚开始看不懂 后来发现 有好多类 都被 internal了,跟本看不见,没法reflector了. DesignerHost 这个类一直找不到,影藏了。下面是 DesignerSurface 的声明, 看了之后就明白了 DesignSurface 和 DesignHost的关系了 public clas原创 2009-08-21 15:21:00 · 657 阅读 · 0 评论 -
WaterMark TextBox
Sometimes I have no other way to implement some marvellous special effects.at this time ,I need WIN api or override wndproc(ref msg) .Like watermark TextBox.... public partial class WaterMark原创 2009-08-21 09:07:00 · 399 阅读 · 0 评论 -
about thread.join
thread.join() 方法的使用对这个方法一直没搞明白,而然在CNBLOGS上看到 线程的插入 Join()函数终于明白。。Thread类的join 方法能够将两个交替执行的线程合并为顺序执行的线程。比如在线程B中调用了线程A的join()方法 ,将线程A插入到线程B中,直到线程A执行完毕后,才会继续执行线程B。 using System;using Syst原创 2009-08-20 10:23:00 · 515 阅读 · 0 评论 -
about attribute
attribute 能够 让我我们想元数据中添加信息,这个对于.net来说很重要,要知道元数据在 .NET中的地位哦。 至于attribute 该用在什么地方,到现在一直没有新的尝试,出来框架提供的几个常用的attribute 是在用之外,自己一直想不出在什么地方改用。 不管怎样 ,写个DEMO 以免太陌生,以后都把他给忘了。 定义一个 attribute原创 2009-08-18 21:38:00 · 329 阅读 · 0 评论 -
写点基础
东西虽然很老套,但是很基础很重要 一个接口的非静态方法总被认为是共有的虚方法,这不可以改变,但是在C#中,如果我们在一个类型内实现接口方法的时候忽略virtual关键字,那么该方法将被认为是一个密封(sealed)的虚方法---继承了该实现类型的其他类型将不可以再重写该方法。 接口和接口及类型之间的转换 public sealed class String : ICo原创 2009-08-17 21:50:00 · 286 阅读 · 0 评论 -
How to use DllImport
大家在实际工作学习C#的时候,可能会问:为什么我们要为一些已经存在的功能(比如Windows中的一些功能,C++中已经编写好的一些方法)要重新编写代码,C#有没有方法可以直接都用这些原本已经存在的功能呢?答案是肯定的,大家可以通过C#中的DllImport直接调用这些功能。DllImport所在的名字空间 using System.Runtime.InteropServices;MSDN中对Dll转载 2009-07-30 09:43:00 · 260 阅读 · 0 评论 -
about Exception and soapSeralization
[Serializable] sealed class DiskFullException : Exception, ISerializable { public DiskFullException():base() {} public DiskFullException(string message)原创 2009-08-23 09:56:00 · 328 阅读 · 0 评论 -
扩展泛型方法
有些时候类库提供给我的方法不够用。比如Queue 没有提供 Clone()方法。 这样代码的表现形式不能为:Queue s=new Queue();s.Enqueeu("ad");//如果想clone一个queue不能表现为下面的代码Queue s2=s.Clone(). 怎么办能,用C#编译器提供的语法糖吧。扩张方法。。。一切搞定 public原创 2009-08-24 11:37:00 · 428 阅读 · 0 评论 -
抽象类和接口的区别
相同点和不同点3.1 相同点 都不能被直接实例化,都可以通过继承实现其抽象方法。 都是面向抽象编程的技术基础,实现了诸多的设计模式。 3.2 不同点 接口支持多继承;抽象类不能实现多继承。 接口只能定义抽象规则;抽象类既可以定义规则,还可能提供已实现的成员。 接口是一组行为规范;抽象类是一个不完全的类,着重族的概念。 接口可以用于支持回调;抽象类不能实转载 2009-09-07 15:08:00 · 421 阅读 · 0 评论 -
一个反射程序集的例子
class Program { static void Main(string[] args) { Assembly assem = Assembly.GetExecutingAssembly(); Reflector.ReflectOnAssembl原创 2009-09-05 09:19:00 · 269 阅读 · 0 评论 -
Create class type dynamically
动态创建class的基本使用方式和enum是一样的,但是 往这个动态类型里添加代码还是一件比较麻烦的事情,这里最好对IL代码需要有所掌握。 static void Main(string[] args) { AppDomain domain = AppDomain.CurrentDomain; AssemblyNam原创 2009-09-06 15:56:00 · 392 阅读 · 0 评论 -
反射检查类型是否实现某个接口
public interface IBookRetailer : IDisposable { void Purchage(); void ApplyDiscount(); } public interface IMusicRetailer { void Purchase(); }转载 2009-09-06 13:18:00 · 1888 阅读 · 0 评论 -
BindAndInvokeTogether
加了一点小代码,和原来的不一样 //#define BindAndInvokeTogetherusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Reflection;na转载 2009-09-05 22:35:00 · 311 阅读 · 0 评论 -
Monitor and mutex
lock 的效果等同于 Monitor 这个编译器又在搞鬼了。不过他的粒度 只能在本程序中,Mutex这个 估计 是在OS中建一个 互斥变量,然后要用的的程序来竞争,竞争到了。就可以继续运行。还是 逃不了 API 的。。。。。。。。。原创 2009-09-02 16:34:00 · 324 阅读 · 0 评论 -
Dispose pattern
Dispose模式是用于资源管理的常用方法,比较简单。给代码吧。 // 摘要: // 定义一种释放分配的资源的方法。 [ComVisible(true)] public interface IDisposable { // 摘要: // 执行与释放或重置非托管资源相关的应用程序定义的任务原创 2009-08-30 10:14:00 · 499 阅读 · 0 评论 -
Reflection conclusion
本文中部分内容参考自:1.Pro C# with .NET 3.0 Special Edition2. http://www.cnblogs.com/JimmyZhang/archive/2008/01/27/Reflection-Part1.html本文中所有源代码下载链接:http://files.cnblogs.com/LinderMan/Exercise.rar一、基本概念反射转载 2009-07-29 12:34:00 · 450 阅读 · 0 评论