随笔分类 - Basic .Net
摘要:vs2010安装svn插件及简单使用1.下载安装程序,安装2.配置vs20103.check out工程1.下载安装程序,安装2.配置vs20103.check out工程Open the project in Solution Explorer.From theFilemenu in Visual Studio, selectSubversion>Change Source Control.In theChange Source Controlwindow, select the row containing your project or solution, and clic
阅读全文
摘要:c#的各种访问修饰符1.各种访问修饰符2.程序集?1.各种访问修饰符访问修饰符说明public公有访问。不受任何限制。private私有访问。只限于本类成员访问,子类,实例都不能访问。protected保护访问。只限于本类和子类访问,实例不能访问。internal内部访问。只限于本项目内访问,其他不能访问。protected internal内部保护访问。只限于本项目(程序集)或是子类访问,其他不能访问C#成员类型的可修饰及默认修饰符如下表:成员类型默认修饰符可被修饰符enumpublicnoneclassprivatepublic、protected、internal、private、 pr
阅读全文
摘要:c#解惑 预处理1.#define2.#if, #else, #elif, #endif3.#undef4.#regionC#中的预处理指令只是实现了c++中的一个子集,关键字的使用是和c++中是相同的。需要注意在cs文件中#define和#undef需要在文件的开始处声明。下面是一个主要框架:// 预处理指令#define DEBUGusing System;using System.Collections.Generic;using System.Linq;using System.Text;static void Main(string[] args) {#if DEBUG Consol
阅读全文
摘要:c#中的值和引用1.c#中的值和引用类型2.传递参数ref1.c#中的值和引用类型2.参数传递ref如果函数中想要改变传递的参数(值类型的)的内部数据的话,可以使用关键字ref。需要注意的是关键字ref可以作为函数重载时函数签名的一部分。
阅读全文
摘要:c#解惑系列1.c#中的值和引用2.预处理3.各种访问修饰符4.对象销毁5.多态6.操作符重载7.接口8.is or as?9.params关键字10.不规则数组11.委托和事件12.程序集和版本控制13.属性和反射14.线程15.序列化16.独立存储空间17.com组件编程
阅读全文
摘要:string 转换成 Char[] string ss="abcdefg"; char[] cc=ss.ToCharArray();Char[] 转换成string string s=new string(c);
阅读全文
摘要:1.在xsd文件中可能存在相互嵌套的情况,这是xsd就无能无力了。 http://geekswithblogs.net/mnf/archive/2008/07/22/generate-c-class-from-xsd-file.aspx | Home |"Login failed for user" may mean "database name is invalid" >> Generate C# class from XSD file. I have an existing C# file, generated a long tim
阅读全文
摘要:Do not repair VS 2008 SP1 from installation mediaIf you need to repair Visual Studio 2008 once SP1 has been applied or wish to change which features are installed, you cannot run setup.exe from the original installation media.When you run repair from media you may see an error like, "A problem
阅读全文
摘要:A delegate is a reference type, like the other reference types you've seen in this book, but instead of referring to an object, a delegate refers to a method. This is called encapsulating the method. When you create the delegate, you specify a method signature and return type; you can encapsulat
阅读全文
摘要:ctrl + A, ctrl + E, F,自动格式化代码。
阅读全文
摘要:If you are working with VS 2010 (any Edition) and cannot open your 2010 solution on VS 2008 then just follow these 3 Steps:For <PROJECT_NAME>.sln:1. Open the solution file in your favorite text editor (ex: notepad++).2. Find the Following:Microsoft Visual Studio Solution File, Format V
阅读全文
摘要:整个设计模式的学习是通过msdn webcast来进行的,首先感谢“李建忠”老师辛勤的讲解(这个视频教程的时间可能是比较老的,好像是05年东西),但是通过整个教程的学习,感觉还是收获很多,对于面向对象有了更深的理解。下面是整个设计模式的总结:Creational PatternsAbstract FactoryCreates an instance of several families of classes,解决的多系列对象创建问题。BuilderSeparates object construction from its representation
阅读全文
摘要:应用场景:在软件的构建过程中,对象的状态改变之后,对象的行为也会随之改变,如何在运行时根据对象的状态透明的更改对象的行为就是state模式解决的问题。实现代码: // 抽象类,表达状态的依赖状态行为 abstract class StateDocument { public abstract void Handler1(); public abstract void Handler2(); public abstract void Handler3(); public abstract StateDocument Next { get; set; } } class ReadOnlyState
阅读全文
摘要:应用场景:在软件的构建过程中,某些对象使用的算法可能多种多样,如果将这些算法直接编码到使用的类中的,这些类的维护旧就成为一个问题。解决的思路是“封装变化点”,将算法首先抽象出一个父类,然后在使用这些算法的类中只保留父类的引用,而传递的就是具体类。实现代码: class Program { static void Main(string[] args) { // 这里动态改变,动态更改算法。 Car car = new Car(new ProcessStrtategyA()); } } enum CarType { A, B, C, D } // 算法抽象
阅读全文
摘要:应用场景:在软件构建过程中,由于需求的变化,某些类层次常常需要新增加新的行为,如果直接改变基类的方法的话,将给子类的维护带来巨大的灾难。解决的思路是使用visitor模式,需要新增加方法的类是不需要改动的,只要实现相应的接口即可。这里是英文解释:Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it o
阅读全文
摘要:应用场景:在软件的构建过程中,某些对象的状态在转换的过程中,可能由于某种的需要,要求程序能够回溯到以前的状态。Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.仅仅是在外部新增加一个类,然后在这个类中保存类的状态信息。实现代码: // 只是封装状态,而不封装其他的方法。 class Rectangle : ICloneable { int x; int y;
阅读全文
摘要:应用场景:Chain the receiving objects and pass the request along the chain until an object handles it.实现代码: class Request { } abstract class BaseHandler { public BaseHandler(BaseHandler next) { this.next = next; } // 下一个可能处理这个request的对象 // 这里相当于链表 private BaseHandler next; public BaseHandler Next { get {
阅读全文
摘要:应用场景:在软件的构建构成中,经常存在多个对象相互交互的情况,这样的话,一个类的改变的话,其他关联的对象都需要改变。解决的办法是在各个对象之间增加一个Mediator中介者,使用这个对象来管理这些对象的交互。实现代码:第一种:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Mediator{ class Program { static void Main(string[] args) { ChatRoom cr = new ChatRoom(); Parti
阅读全文
摘要:应用场景:Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.给定一个语言,定义它的发文的一种的表示,并定义一种解释器,使用这个解释器来解释这些句子。实现代码: class Program { static void Main(string[] args) { string roman = "MCMXXVIII"; Conte
阅读全文