Posted on

C# Namespace Guidelines

Let’s create some guidelines for documenting .Net Namespace.

For example, let’s look at the System.Collections Namespace. What do we notice?

Namespace – define the namespace using the following convention: System.Collections Namespace

Purpose – describe the purpose of the namespace, for example:

crone-park (33)


The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries.


We then identify the classes related to the namespace. For each, we identify it and describe its purpose. Use the correct case when documenting the

Note: it’s ArrayList, not Arraylist or arrayList.

Class Description

ArrayList – implements the IList interface using an array whose size is dynamically increased as required. Note how IList is spelt. Both the I for
Interface and L for List are capitalized.

BitArray – manages a compact array of bit values, which are represented as Booleans. True indicates that the bit is on (1). False indicates the bit is off

CaseInsensitiveComparer – compares two objects for equivalence, ignoring the case of strings.

CaseInsensitiveHashCodeProvider – Obsolete.


Next, identify the structure related to the namespace.

Structure Description

Dictionary Entry Defines a dictionary key/value pair that can be set or retrieved.


For interfaces, note the casing for IDictionaryEnumerator. I for Interface and D for Dictionary and E for Enumerator are capitalized.

Interface Description

ICollection – Defines size, enumerators, and synchronization methods for all nongeneric collections.

IComparer – Exposes a method that compares two objects.

IDictionary – Represents a nongeneric collection of key/value pairs.

IDictionaryEnumerator – Enumerates the elements of a nongeneric dictionary.

Use verb constructions to describe the purpose of each interface.

Posted on

What is a Statement in C#?

In C#, statements express the actions that a program takes.

Common actions include

  • Declaring variables
  • Assigning values
  • Calling methods
  • Looping through collections
  • Branching to another block of code

crone-park (35)

The order in which statements are executed in a program is called the

  • flow of control or
  • flow of execution.

This may vary every time that a program is run, depending on how the program reacts to input that it receives at run time.

A statement consist of one of the following:

  • Single line of code that ends in a semicolon or
  • Series of single-line statements in a block

A statement block is enclosed in {} brackets and can contain nested blocks.



Posted on

C# – What is a derived class?

As the name implies, a derived class originates from another class, which in C# is called a base class.

A derived class is a specialization of the base class. A derived class is created from an existing base class. It inherits the member variables and methods of the base class from which it is derived.

For example, if you have a base class Music, you might have a derived class Classical and another derived class StringQuartet.

While Classical derives from Music, and StringQuartet derives from Music, each derived class can represent different specializations of the base class Music.

crone-park (24)

What is a derived class?

When you define a class to derive from another class, the derived class gains all the members of the base class – except its constructors and destructors.

This means the derived class can reuse the code in the base class without re-implementing it.

In the derived class, you can add more members allowing it to extend the functionality of the base class.

  • Base Class – members are inherited by the derived class.
  • Derived Class – inherits those members from the base class.

Each Derived Class Has Only One Direct Base Class

A derived class can have only one direct base class.

However, inheritance is transitive.


StringQuartet is derived from Classical

Classical is derived from Music

StringQuartet inherits the members declared in Classical and Music.

Polymorphism and Derived Classes

Polymorphism let us treat objects of a derived class as objects of its base class.

For example, big cats (base class) hunt (a method) in different ways. A Lion (derived class) stalks, while a Cheetah (another derived class) outruns it.

Virtual Methods

A virtual method is a type of method which can be overridden in a derived class.

Tip: use override sealed if you want a virtual method in a base class to become sealed in a derived class.

MSDN Definition

A class that was created based on a previously existing class (i.e., base class). A derived class inherits all of the member variables and methods of the base class from which it is derived.

C+ Derived Class Example

class Derived : [virtual] [access-specifier] Base


// member list


class Derived : [virtual] [access-specifier] Base1,

[virtual] [access-specifier] Base2, . . .


// member list



Note: In C#, both inheritance and interface implementation are defined by the : operator, equivalent to extends and implements in Java. The base class should always be rightmost in the class declaration.

Single Inheritance

In “single inheritance,” a form of inheritance, classes have only one base class.

Consider the relationship illustrated in the following figure.




Note the progression from general (PrintedBook) to specific (PaperbackBook).

Kind of Relationships

The derived class has a “kind of” relationship with the base class.


A Book is a kind of a PrintedDocument

A PaperbackBook is a kind of a book.

Book is

both a derived class (from PrintedDocument) and a

base class (as PaperbackBook is derived from Book).

Code Sample

class PrintedDocument {};

// Book is derived from PrintedDocument.

class Book : public PrintedDocument {};

// PaperbackBook is derived from Book.

class PaperbackBook : public Book {};

Direct Base v Indirect Base

PrintedDocument is a “direct base” class to Book.

PrintedDocument is an “indirect base” class to PaperbackBook.


A direct base class appears in the base list of a class declaration – an indirect base does not.

The base class from which each class is derived is declared before the declaration of the derived class.

Learn more at

Posted on 4 Comments

7 Ways to Improve Your Technical Writing

Here are seven quick tips to improve the quality of your technical documents. Continue reading 7 Ways to Improve Your Technical Writing