六 合 彩:

- “ϵԒ - - У· - VӅ^ɽ·A@^3307(AT)
Fڵλã ӋCӖ >> Ӗ̳ >> C# >> 
C#a66T ߣӋC࡭    ̳́ԴVӋCӖ    c    •rg2010-12-3

ϴȫ www.wzfng.com 1.  ⌢һļ

2.  һļԓֻһg⌢gͬһļ

3.  һļòҪ^500еĴaCaĴa

4.  һĴaLòҪ^25

5.  ⷽг^5rʹýYf

6.  ÿдaҪ^80ַ

7.  Ҫֹ޸ęCaĴa

a)  Ҫ݋CaĴa݋ʽLҪԓa˜

b)  Use partial classes whenever possible to factor out the maintained portions.

8.  עጽ@ҊĴa

a)  aԓԽõĴaɿx׃ͷ˲Ҫע

9.  Document only Operational assumptions, algorithm insights and so on.  

10.  ʹ÷ęn

a)  ʹÔUչAPIęnf֮

b)  ֻԓҪ_lʹõĕrʹ÷עC#о///

11.  ҪӲaֵֵʹØ캯Oֵ

12.  ֻȻYֱʹconstһڵ씵

13.  ֻx׃ʹconst댍Fֻxֱʹreadonly

public class MyClass

{

   public readonly int Number;

   public MyClass(int  someValue)

   {

      Number = someValue;

   }

   public  const int  DaysInWeek = 7;

}

14.  ÿOʹAssertz

a)  ƽÿ15ҪһΙz(Assert)

using System.Diagnostics;

 

object GetObject()

{}

 

object obj = GetObject();

Debug.Assert(obj != null);

15.  aÿһжԓͨ^׺зʽĜyԇ

16.  ֻѽ@ʾ̎Į

17.  ڲ@(catch)ZĒӾ(throw)ǒԭʼSoԭʼe`Ķї

catch(Exception exception)

{   

   MessageBox.Show(exception.Message);

   throw ;  //throw exceptionһ

}

18.  ⷽķֵe`a

19.  MⶨxԶx

20.  ҪxԶxĮr

a)  ԶxҪ^applicationException

b)  ṩԶxл

21.  چ΂ʹöMain

22.  ֻ⹫ҪIJĄtinternal

23.  Avoid friend assemblies, as it increases inter-assembly coupling.

24.  Avoid code that relies on an assembly running from a particular location.

25.  ʹó򼯱MСa(EXE͑)ʹQ̄߉݋

26.  oöe׃ṩ@ʽֵ

//_ 

public enum Color

{   

   Red,Green,Blue

}

//

public enum Color

{   

   Red = 1,Green =  2,Blue = 3

}

27.  ָ͵öe׃

// 

public enum Color  : long

{   

   Red,Green,Blue

}

28.  ʹifZֻһҲҪifZăô̖U

29.  ʹtrinaryl

30.  ڗlZ{÷boolֵĺ?ʹVֲՏTֲ?

bool IsEverythingOK()

{}

//

if (IsEverythingOK ())

{}

//Q 

bool ok = IsEverythingOK();

if (ok)

{}

31.  ʹû0_ʼĔM

32.  ѭhп@ʽijʼ͵ĔM

public class MyClass

{}

MyClass[] array = new  MyClass[100];

for(int index = 0; index < array.Length;  index++)

{

   array[index] = new  MyClass();

}

33.  Ҫṩpublic PRotectedijɆT׃ʹÌԴ

34.  ^ʹnewʹoverrideQ

35.  ڲsealedпnjpublic protectedķӛvirtual

36.  ʹinterop(COM+ dll)atҪʹòȫĴa(unsafe code)

37.  @ʾDQʹasMм͵DQ

Dog dog = new GermanShepherd();

GermanShepherd shepherd = dog  as  GermanShepherd;

if (shepherd != null )

{}

38.  ɆTίеĕr

a)  Copy a delegate to a local variable before publishing to avoid concurrency race

condition. 

b)  {ί֮ǰһҪzǷnull

public class MySource

{

   public event EventHandler  MyEvent;

   public void FireEvent()

   {

      EventHandler temp = MyEvent;

      if(temp != null )

      {

         temp(this,EventArgs.Empty);

      }

   }

}  

39.  Ҫṩ¼ɆT׃ʹ¼LQ@Щ׃

public class MySource

{

   MyDelegate m_SomeEvent ;

   public event MyDelegate SomeEvent

   {

      add

      {

         m_SomeEvent += value;

      }

      remove

      {

         m_SomeEvent -= value;

      }

   }

}

40.  ʹһ¼¼Ķx

41.  ʹýӿ

42.  ͽӿеķ͌ٞ2:1ı

43.  һӿֻһɆT

44.  Mʹÿӿа35ɆT

45.  ӿеijɆTԓ^20

a)  Hrƞ12

46.  ӿڳɆTа¼

47.  ʹó󷽷ʹýӿQ

48.  Ӵ@ʾӿ

49.  ]ʹ@ʽĽӿڌF

50.  IJOһͼһӿDefensively query for that interface.

SomeType obj1;

IMyInterface obj2;

 

/* Oдaʼ^obj1 */

obj2 = obj1 as IMyInterface;

if (obj2 != null)

{

   obj2.Method1();

}

else

{

   //̎e`

}  

51.  FoKÑַҪʹӲaҪʹYԴļQ֮

52.  ҪӲaܸĵĻõַBַ

53.  ҪLַĕrʹStringBuilderҪʹstring

54.  ڽYṩ

a)  hʹÅ캯

b)  زò

55.  ҪooB׃ṩoB캯

56.  ʹڽͲҪʹúڽ

57.  ʹÑó־͸ۙ

58.  ڲȫswitchZзtҪʹgotoZ

59.  switchZпҪdefaultӾ@ʾϢ(Assert)

int number  = SomeMethod();

switch(number)

{

   case 1:

      Trace.WriteLine("Case 1:");

      break;

   case 2:

      Trace.WriteLine("Case 2:");

      break;

   default :

      Debug.Assert(false);

      break;

}

60.  ژ캯{캯tҪʹthisָ

// _ʹthis

public class MyClass

{

   public MyClass(string message )

   {}

   public MyClass()  : this("hello")

   {}

}

61.  ،дQ_ͻijɆT{ûĘ캯tҪʹbaseLijɆT

// _ʹbase

public class Dog

{

   public Dog(string name)

   {}

   virtual public void Bark( int howLong)

   {}

}

public class GermanShepherd : Dog

{

   public GermanShe pherd(string name): base (name)

   {}

   override public void Bark(int  howLong) 

   {

      base .Bark(howLong);  

   }

}

62.  ģĕrҪFDispose()Finalize()ɂ

63.  ͨr±ЏSystem.ObjectDQSystem.ObjectDQȥĴaʹÏDQasQ

class SomeClass

{}

//⣺

class MyClass<T> 

{   

   void SomeMethod(T t)   

   {

      object temp = t;      

      SomeClass obj = (SomeClass)temp;    

   }

}

// _

class MyClass<T> where T : SomeClass

{   

   void SomeMethod(T t)   

   {

      SomeClass obj = t;   

   }

}

64.  һr²ҪӰƷĽӿӿڵƼeͨ?s滻?

public class Customer

{}

//⣺

public interface IList<T> where T : Customer 

{}

//_

public interface ICustomerList : IList<Customer> 

{}

65.  _ڽӿڃȵľwƗl

66.  xʹC#ãһgenericsĔY


Y://www.knowsky.com/343529.html

WУ· |Wվ؈D| ϴȫ Copyright 2006-2016 All Rights Reserved VϢԃ޹˾ 䰸/SC̖ICP11070650̖-9 B̩˱BϢg޹˾VӋCWУӖW ٷWַϴȫ www.wzfng.com ˾ַVӅ^ɽ·AWƼ@A@^3307AT