03 2011 档案
摘要:你要部署silverlight的环境是什么样的?我的是Win7+IIS7部署Silverlight4的发布程序我的发布可以的!(这个也让我郁闷了几天,今天在看老外的帖子的时候,尝试了下竟然可以了)大致把我所经历几个步骤说一下(不一定每个步骤有必须设置,也不一定对,因为没有单独测试),准备这几天详细总结下。下面是一个大致的步骤,你可以暂时参考下!(1)如果不是在装有开发环境机器里发布,要装.netframework4.0(注意我的部署环境和部署对象),并在IIS中设置其为.netframework4.0(2)在生成部署包之前,据说是要将*.web下的“引用”下的几个dll复制到本地(System
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//组合接口//1.通过组合接口不仅可以在语义上相关多个接口组合成单个接口,还可以在需要时将方法添加进新的组合接口namespace InterfaceApp{ public class Control { } public interface IDragDrop { void Drag(); void Drop(); } public interface ISerializable { void Serialize(); } //
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//接口//1.接口是C#基于组件编程的重要部分//2.接口使你能够在独立的代码段之间创建一致的行为契约(更面向对象、更灵活)//3.接口基本上是一个抽象类,其中只声明了纯虚方法和C#成员//4.接口中可以包含方法、特性、索引器和事件,但这些都不是在接口本身中实现的//5.不能在接口成员(方法、事件、索引、属性)上指定访问修饰符namespace InterfaceDemo{ public delegate void testEve
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AbstractDemo{ public abstract class Sharp { //1.抽象方法,不含主体 //2.必须由派生类以override方式实现此方法 //3.抽象方法所在类必须为抽象类 public abstract void GetArea(); } public class Circle : Sharp { private double r; public Circle(double r)
阅读全文
摘要:首先理解一下什么叫多态。同一操作作用于不同的对象,可以有不同的解释,产生不同的执行结果,这就是多态性。多态性通过派生类覆写基类中的虚函数型方法来实现。多态性分为两种,一种是编译时的多态性,一种是运行时的多态性。编译时的多态性:编译时的多态性是通过重载来实现的。对于非虚的成员来说,系统在编译时,根据传递的参数、返回的类型等信息决定实现何种操作。运行时的多态性:运行时的多态性就是指直到系统运行时,才根据实际情况决定实现何种操作。C#中运行时的多态性是通过覆写虚成员实现。下面我们来分别说明一下多态中涉及到的四个概念:重载,覆写,虚方法和抽象方法。重载和覆写的区别:重载类中定义的方法的不同版本 pub
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace InheritanceApp{ class Employee { public string name; public Employee(string name) { this.name = name; } public virtual void CalculatePay() { Console.WriteLine("Employee.CalculatePay called for {0}",
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace InheritanceApp{ class Employee { public string name; public Employee(string name) { this.name = name; } public void CalculatePay() { Console.WriteLine("Employee.CalculatePay called for {0}",name); }
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace InheritanceApp{ class Employee { public void CalculatePay() { Console.WriteLine("Employee.CalculatePay()"); } } class SalariedEmployee : Employee { //如果去掉new出现如下警告 //警告:“InheritanceApp.SalariedEmplo
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//封闭类不能派生子类//原因:封闭类不能被作为基类使用//好处:防止意外的派生的操作//注意:抽象类不能作为封闭类使用(抽象类本质决定了他们必须被作为基类使用)namespace InheritanceApp{ sealed class Point { public Point(int x, int y) { X = x; Y = y; } public int X; public int Y; } //语法错误:无法从密封类型P
阅读全文
摘要://继承 //1.C#中实现多继承效果的唯一办法是通过使用接口 class Control { } interface ISerializable { } interface IDataBound { } //MyFancyGrid继承自Control实现了ISerializable和IDataBound接口 class MyFancyGrid : Control, ISerializable, IDataBound { } 下面做法是错误的。
阅读全文
摘要:1、排序方法 将被排序的记录数组R[1..n-1]垂直排列,每个记录R[i]看作是重量为R[i].key的气泡。根据轻气泡不能在重气泡之下的原则,从下往上扫描数组R:凡扫描到违反本原则的轻气泡,就使其向上"飘浮"。如此反复进行,直到最后任何两个气泡都是轻者在上,重者在下为止。(1)初始 R[1..n-1]为无序区。(2)第一趟扫描 从无序区底部向上依次比较相邻的两个气泡的重量,若发现轻者在下、重者在上,则交换二者的位置。即依次比较(R[n-1],R[n-2]),(R[n-2],R[n-3]),…,(R[1],R[0]);对于每对气泡(R[j+1],R[j]),若R[j+1]
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//继承//1、继承本质:将共有的功能放在基类中,然后从这个基类派生出其他类,并且重定义或修改继承的基类行为。//2、派生类可以继承基类中public、protected、internal的几乎所有成员,但构造器不能被继承namespace InheritanceApp{ //假设需要一个用于处理Microsoft SQL Server数据库和Oracle数据类。因为这两个数据库在某些方面有差异,所以希望为每种数据建立一个类。 //
阅读全文
摘要:1、二分查找(Binary Search) 二分查找又称折半查找,它是一种效率较高的查找方法。 二分查找要求:线性表是有序表,即表中结点按关键字有序,并且要用向量作为表的存储结构。不妨设有序表是递增有序的。2、二分查找的基本思想 二分查找的基本思想是:(设R[low..high]是当前的查找区间)(1)首先确定该区间的中点位置: (2)然后将待查的K值与R[mid].key比较:若相等,则查找成功并返回此位置,否则须确定新的查找区间,继续二分查找,具体方法如下: ①若R[mid].key>K,则由表的有序性可知R[mid..n-1].keys均大于K,因此若表中存在关键字等于K的结点,则
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//如何运行前不知道的值传递给 CommandDelimitedFile构造器?答案:使用静态方法,与base关键字一起使用。namespace InitialConstruct{ class CommandDelimitedFile { public CommandDelimitedFile(string fileName) { Console.WriteLine("[CommandDelimitedFile."
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace InitialConstruct{ class BaseClass { public BaseClass() { Console.WriteLine("[BaseClass.BaseClass] " + "Construct called"); } public BaseClass(int foo) { Console.WriteLine("[BaseClass.
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//构造器初始化//1.派生类构造器调用基类构造器(除System.Object构造器外,所有C#对象都在执行构造器的第一行代码之前调用基类构造器)//2.初始化器的两种形式:// (1)base() 调用当前类的基类构造器// (2)this() 可以让当前类调用自身中定义的另一个构造器namespace InitialConstruct{ class BaseClass { public BaseClass() { Consol
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//静态成员//1.只存在此成员的一个副本//2.当包含在这个类的应用程序被装载时,才创建静态成员//3.在应用程序的整个生存周期内存一直存在。//4.是值类型:静态成员必须有合法的值namespace StaticMember{ class InstCount { public InstCount() { instanceCount++; } static public int instanceCount; } class Pro
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//静态构造器//1.只能有一个静态构造器//2.静态构造器上不允许使用public和private等修饰符//3.静态构造函数必须无参数//4.可以提供一个具有与静态构造器相同的原型的非静态构造器,先调用静态版本//5.在访问类的任何静态成员(函数或数据)之前执行静态构造器namespace StaticConstructor{ class SomeClass { public static int x; public int y
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//1.静态方法可以访问类中的所有静态成员,但不能访问实例成员//2.非静态方法可以访问静态成员和非静态成员//3.在构造器中只能对非静态成员使用this关键字namespace StaticMethod{ class SQLServerDb { static string progressString1="starting repair..."; string progressString2="...
阅读全文