잊지 않겠습니다.

The Common Language Runtime(CLR) provides a common platform for the execution of programs in .NET.

.NET language is first translated into the Microsoft Intermediate Language(MSIL).

   

Type alias size doesn't match what you're familiar with

Common Language Specification(CLS)의 특징

  • cross-language integration
  • type safety
  • high-performance execution of managed code

WinAPI의 DllImport 시에 Type 값은 서로간에 byte size를 맞춰줄 필요가 있다.

   

Structure and Class differ in behavior

  • class(reference type) : be created on the heap
  • structure(value type) : be created on the stack

   

Returning value types from a method/property is risky

: Value type으로 return을 받을 경우와 Reference type으로 return을 받을 때, 동작을 유의해야지 된다.

DateTime dtDate = DateTime.Now; <- value type

dtDate.AddDate(1) <- dtDate 값은 변화하지 않음.

   

You can't force calls to your value-type constructors

  • value-type constructor에서 일반 생성자를 호출하는 것은 불가능하다.
  • 값의 초기화를 초기값(int :0, boolean : false) 이외에 값으로 초기화 하는 것이 불가능하다.

   

String concatenation is expensive

  • string에서 string의 모음에서 +를 이용하는 것보다, StringBuilder.Append()를 이용해서 string을 모으는 것이 좋다.
  • 1000000번 '.'를 결합할때, +를 사용하는 경우에는 3562.933 sec가 소요되며, StringBuilder를 사용하는 경우에는 0.07sec의 시간이 소요된다.

   

Exceptions may go unhandled

  • Windows app에서는 Application.ThreadException을 handling 시켜주고, Console app에서는 AppDomain.CurrentDomain.UnhandledException을 handling 시켜줘서 사용해준다.
  • 사용자에게 넘겨주는 모든 error를 사용자에게 넘기지 않고, 내부에서 처리가 되어야지 된다.

   

Uninitialized event handlers aren't treated gracefully

Delegate 된 event의 경우에는 연결되지 않을 경우에는 null reference error가 발생한다.

모든 Event를 동작할 때는 반드시 event의 null point error를 check를 해주는 것이 필요하다.

   

Division operation isn't consistent between types

  • 0로 나뉠때 나오는 에러인 DivisionByZeroException이 나올때, double로 나누어질 때는 eps또는 (+-) 무한대로 나타날 수 있기 때문에, DivisionByZeroException이 나타나지 않을 수 있다.
  • 0로 나뉘어지는 것이 우려될 때는 , IsInfinity() method를 호출해서 값의 형태를 확인해봐야지 된다.

   

Typeless ArrayList isn't type-safe

 System.Collections.ArrayList에서는 모든 데이터가 reference type으로 들어가는 것이 가능하지만, 그 값은 type 변환에 안전하지 못하다.

주의해서 사용하거나, System.Generic을 이용해서 type-safe로 만들어주는 것이 좋다.

  

Type.GetType() may not locate all types

선언되어 있는 class library에서 여러개의 중복된 이름을 가질 수 있기 때문에, 하나의 이름만으로 모든 것을 다 얻어내는 것은 불가능하다. 이때에는 reference type name과 version, public key를 모두 적어줘야지 인식시킬 수 있다.

  

Public key reported by sn.exe is inconsistent

"sn.exe -k"로 key를 만들어줄때는 각 key는 private key만이 갖고 있다. public key는 private key에 pair로 만들어서 서명하는 형식으로 만들어줘야지 된다. Visual Studio 2000에서는 "sn.exe -t" 옵션이 잘못 동작하고 있었다. (구버젼을 사용하는 경우에 주의 할것)

Posted by Y2K
,