CLR via C#

最新书摘:
  • DeepLearning
    2014-04-23
    The reason a type that defines Equals must alson define GetHashCode is that the implementation of the System.Collections.Hashtable type, the System.Collections.Generic.Dictionary type, and some other collections require that any two objects that are equal must have the same hash code value. So if you override Equals, you should override GetHashCode to ensure that the algorithm you use for calculating equality corresponds to the algorithm you use for calculating the object’s hash code.Basically, when you add a key/value pair to a collection, a hash code for the key object is obtained first. This hash code indicates which "bucket" the key/value pair should be stored in. When the collection needs to look up a key, it gets the hash code for the specified key object. This code identifies the "...
  • DeepLearning
    2014-04-16
    Here is how to properly implement an Equals method internally:1. If the obj argument is null, return false because the current object identified by this is obviously not null when the nonstatic Equals method is called.2. If the this and obj arguments refer to the same object, return true. This step can improve performance when comparing objects with many fields.3. If the this and obj arguments refer to objects of different types, return false.4. For each instance field defined by the type, compare the value in the this object with the value in the obj object. If any fields are not equal, return false.5. Call the base class’s Equals method so it can compare any fields defined by it, if the base class’s Equals method returns false, return false; otherwise, return true.
  • DeepLearning
    2014-04-10
    Any data types the compiler directly supports are called primitive types. Primitive types map directly to types existing in the Framework Class Library (FCL).
  • DeepLearning
    2014-04-09
    When a thread is created, it is allocated a 1-MB stack. This stack space is used for passing arguments to a method and for local variables defined within a method. Stacks build from high-memory addresses to low-memory addresses.All but the simplest of methods contain some prologue code, which initializes a method before it can start doing its work. These methods also contain epilogue code, which cleans up a method after it has performed its work so that it can return to its caller.
  • DeepLearning
    2014-04-08
    The C# compiler, by default, automatically looks in the MSCorLib.dll assembly even if you don’t explicitly tell it to. The MSCorLib.dll assembly contains the definitions of all of the core Framework Class Library (FCL) types, such as Object, Int32, String, and so on.
  • DeepLearning
    2014-04-08
    The C# using directive instructs the compiler to try prepend-ing different prefixes to a type name until a match is found.The compiler will scan all of the referenced assemblies looking for the type’s definition. After the compiler finds the proper assembly, the assembly information and the type information is emitted into the resulting managed module’s metadata.To get the assembly information, you must pass the assembly that defines any referenced types to the compiler.
  • byhard
    2013-04-09
    Different languages offer different capabilities.For example, in unmanaged C/C++, you have pretty low-level control of the system. You can manage memory exactly the way you want to, create threads easily if you need to, and so on. Microsoft Visual Basic 6.0, on the other hand, allows you to build UI applications very rapidly and makes it easy for you to control COM objects and databases.
  • LK
    2012-07-06
    代码引用一个常量时,编译器会在定义常量的程序集的元数据中查找该符号,提取常量的值,并将值嵌入生成的IL代码中。