what is threading?

May 7, 2009

It is to perform multiple operations concurrently. Each of these operations can be thought of as a separate thread of logic.

……

Shallow/Deep copy

April 1, 2009

The Object.MemberwiseClone method returns a member-by-member copy of the current object. Although values and references are duplicated, subobjects are not. This type of cloning is called a shallow copy. To achieve a shallow (or bitwise) copy, the method Object.MemberwiseClone is simply invoked for the current object. In this way, all the non-static value and reference fields are copied. Although a shallow copy of a value field is non-problematic, the shallow copy of a reference-type field does not create a duplicate of the object to which it refers. Hence, several objects may refer to the same subobjects. The latter situation is often undesirable and therefore, a deep copy is performed instead. To achieve a deep copy, the method Object.Memberwiseclone is invoked for the current object and its subobject(s).

Declare partial class

April 1, 2009

Using the prefix partial before the class name, C# 2.0 different parts of a class can be distributed across different files. Two key restrictions, however, must be satisfied.

  1. all parts of a partial type must be compiled together in order to be merged at compile-time.
  2. already compiled types are not allowed to be extended to include other partial types.

All the partial classes must have the same modifiers as followed:

  • public
  • private
  • protected
  • internal
  • abstract
  • sealed
  • new
  • generic constraints

using alias = namespaceName;

Using alias qualifier :: allows the alias to be referenced even if the conflict of class/method name exists.

using intr0 = wrox.procsharp.basics;

……

   intro::NamespaceExample a = new intro::NamespaceExample();

……

Nested namespaces

April 1, 2009

There are two ways to declare nested namespaces:

  1. namespace Compilers {
       namespace C {
            class Lexer { … }
       }
    }
  2. namespace Compilers.C.Lexer { … }

The second way is good for separated files.

Follow

Get every new post delivered to your Inbox.