随笔分类 -  .NET基础

摘要:Enum.GetValues方法:检索指定枚举中常数值的数组。反编译代码:[ComVisible]public static Array GetValues(Type enumType){ if(enumType==null) { throw new ArgumentNullException("enumType"); } return enumType.GetEnumValues();}[DllImport("QCall",CharSet=CharSet.Unicode)]private static extern void GetEnumValued 阅读全文
posted @ 2012-05-18 22:03 szjdw 阅读(3195) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Reflection;namespace Tool{ public class CustomAttribute { public static string GetCustomAttribute<T>(Type type) where T:System.Attribute { return type.GetCustomAttributes(typeof(T), false)[0] as stri 阅读全文
posted @ 2012-05-11 17:45 szjdw 阅读(182) 评论(0) 推荐(0)
摘要:有限状态机(finite-state machine,fsm),又称有限状态自动机,简称状态机,是表示有限个状态以及在这些状态之间的转移和动作等行为的数学模型。概念和术语状态存储关于过去的信息,就是说:它反映从系统开始到现在时刻的输入变化。转移只是状态变更,并且用必须满足来确使状态转移发生的条件来描叙她。动作是在给定时刻要进行的活动的描述。有多种类型的动作:进入动作(entry action):在进入状态时进行退出动作:在退出状态时进行输入动作:依赖于当前状态和输入条件进行转移动作:在进行特定转移时进行fsm(有限状态机)可使用上面图那样的状态图(或状态转移图)来表示。此外可以使用多种类型的状 阅读全文
posted @ 2012-05-11 16:40 szjdw 阅读(309) 评论(0) 推荐(0)
摘要:存储过程create proc test4@res varchar(10) outputasselect @res=count(*) from Ship_TUser_Infogocs文件:SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@res", SqlDbType.Int) }; paras[0].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTran 阅读全文
posted @ 2012-05-10 16:23 szjdw 阅读(199) 评论(0) 推荐(0)
摘要:SqlParameter类的SQlValue与Value的区别:msdn说:SqlVaue是Sql类型的参数值以字符串类型来说,Sql类型有varchar,nvarchar,char等等C#类型有string,字符数组等等SqlValue指代Sql类型的值Value表示C#类型的值在存储结构上及表示范围、精度等方面有区别。 阅读全文
posted @ 2012-05-09 19:54 szjdw 阅读(740) 评论(0) 推荐(0)
摘要:///<summary>///Parses the specified block of a text///</summary>///<return>///Returns the end position of a parsed block.///</return>protected int ParseBlock(XmlNode parentNode,TagBase parentTag,string text,int position){ #region check the arguments if(parentNode==null) { thr 阅读全文
posted @ 2012-05-07 20:08 szjdw 阅读(183) 评论(0) 推荐(0)
摘要:///<summary>///the name of the Value xml node.///</summary>protected const string cValueXmlAttributeName="Value";///<summary>///Retrieves the value of the specified tag xml node.///</summary>protected string GetXmlNodeValue(XmlNode node){ if(node==null) { throw new 阅读全文
posted @ 2012-05-07 15:27 szjdw 阅读(154) 评论(0) 推荐(0)
摘要:///<summary>///the name of the Tag xml node.///</summary>protected const string cTagXmlNodeName="Tag";///<summary>///Determines whether the specified node is a tag node///</summary>protected bool IsTagXmlNode(XmlNode node){ if(node==node) { throw new ArgumentNullExc 阅读全文
posted @ 2012-05-07 15:16 szjdw 阅读(138) 评论(0) 推荐(0)
摘要:///<summary>///Check whether there is the tag at the specified position in the specified sql///<sumary>///<name>The value of the Name property</name>///<returns>///The position after the tag or -1 there is no tag at the position.///</returns>internal static int Ma 阅读全文
posted @ 2012-05-07 11:39 szjdw 阅读(222) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Reflection;using System.Collections;namespace Tool{ public class DataTable2Object { /// <summary> /// Convert an DataRow to an object /// </summary> /// <typeparam name=&qu 阅读全文
posted @ 2012-05-02 17:20 szjdw 阅读(896) 评论(0) 推荐(0)
摘要:ado.net2.0 增强了数据提供程序的架构,并引入了工厂类,每个.net数据提供程序包括一个派生于基类DbProviderFactory的工厂类,工厂类表示该提供程序特有的各种服务的入口点。下面列出了一个工厂类的主要方法:CreateCommand 返回一个提供程序特有的命令对象CreateCommandBuilder 返回一个提供程序特有的命令创建者对象CreateConnection 返回一个提供程序特有的连接对象CreateDataAdapter 返回一个提供程序特有的适配器对象CreateParameter返回一个提供程序特有的参数对象如何获得一个特有的数据提供程序的工厂呢?通过使 阅读全文
posted @ 2012-04-24 17:36 szjdw 阅读(384) 评论(0) 推荐(0)
摘要:模糊查询like的用法如下:sql对like操作中的特殊字符处理方法:sql server查询过程中,单引号'是特殊字符,所以在查询的时候要转换成双单引号''。在like操作还有以下特殊字符:下划线_,百分号%,方括号[],尖号^。其用途如下:_:用于代替一个任意字符(相当于正则表达式中的?)%:用于代替任意数目的任意字符(相当于正则表达式中的*)[]:用于转义(事实上只有左方括号用于转义,右方括号使用最近优先原则匹配最近的左方括号)^:用于排除一些字符进行匹配以下是一些匹配的举例,需要说明的是,只有like操作才有这些特殊字符,=操作是没有的a_b... a[_]%a 阅读全文
posted @ 2012-04-23 18:48 szjdw 阅读(545) 评论(0) 推荐(0)
摘要:Question:I am using Windbg to disassembly managed code (written in c#,console application) using Windbg's !U command from sos.dll.I find when using !u to disassemble a managed function ,the disassebled IL code only contains function calls i made ,and for remaining parts(non-function call C# code 阅读全文
posted @ 2012-04-21 16:30 szjdw 阅读(210) 评论(0) 推荐(0)
摘要:AttributeUsage类是一个预定义的属性类,以帮助我们控制自定义属性的使用.也就是我们可以定义自定义属性类的属性.这个类描述了如何使用自定义的属性类.AttributeUsage有三个数据属性可用以修饰我们的自定义的属性.ValidOn 定义了自定义属性在哪些程序实体上可被使用.这个可使用实体列表可通过 AttributeTargets枚举类型的OR操作进行设置AllowMutiple 定义了是否可在同一个程序实体上同时使用多个属性进行修饰Inherited 定义了自定义的修饰是否可由被修饰类的派生类继承 让我们做点具体的吧。我们将会用一个AttributeUsage属性修饰我们的属. 阅读全文
posted @ 2012-04-20 11:14 szjdw 阅读(240) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Reflection.Emit;namespace ConsoleApplication1{ public delegate System.String FeedbackToString(); class Program { static void Main(string[] args) { DynamicMethod dynamicMethod = new DynamicMethod(System.Str 阅读全文
posted @ 2012-04-18 15:12 szjdw 阅读(637) 评论(0) 推荐(0)
摘要:Loads the element containing an object reference at a specified array index onto the top of the evaluation stack as type O(object reference).The stack transitional behavior,in sequential order,is:1,An object reference array is pushed onto the stack;2,An index value index is pushed onto the stack;3,i 阅读全文
posted @ 2012-04-17 14:48 szjdw 阅读(287) 评论(0) 推荐(0)
摘要:今天看到博客园一篇文章写抽象类实例化,net framework是ms的,我改不了abstract。但是抽象类是可以做出实例化效果的。为了增强记忆,把代码抄一遍吧!protected sealed override Delegate CombineImp(Delegate follow){ if(base.GetType()!=follow.GetType()) { throw new Exception(); } Delegate delegate2=(MulticastDelegate)((MulticastDelegate)follow).MemberwiseClone()... 阅读全文
posted @ 2012-04-06 19:26 szjdw 阅读(147) 评论(0) 推荐(0)
摘要:方法一:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Class1 { static void Main(System.String[] args) { for (System.Int32 i = 0; i < 5;i++ ) { new Set(3).ProcessingItem(Class1.FeedbackToConsole); } Console.Read(); } static void 阅读全文
posted @ 2012-04-06 10:51 szjdw 阅读(285) 评论(0) 推荐(0)
摘要:错误1“ConsoleApplication1.Test”不能从特殊类“System.MulticastDelegate”派生D:\xgc\0331\Solution1\ConsoleApplication1\Program.cs5211ConsoleApplication1不能从特殊类System.MuticastDelegate派生! 阅读全文
posted @ 2012-03-31 11:17 szjdw 阅读(202) 评论(0) 推荐(0)
摘要:看C#代码:internal class Program{ // Fields private string _isSuper; // Methods private static void Main(string[] args) { Program program = new Program(); if (program._isSuper == "qwe") { Console.WriteLine("There is a1 Exception!"); } Console.Read(); }}msil看看:.class private auto ansi 阅读全文
posted @ 2012-03-22 17:50 szjdw 阅读(289) 评论(0) 推荐(0)