Namespaces

A namespace helps you to divide and conquer the complexity of the object hierarchy.
The .NET Framework organises its classes into namespaces
examples SS


Avoid defining types in the global namespace
The same namesapce can exist in multiple files
It is possible to nest namespace declarations


A collection of logically related types
Namespaces can be nested
avoids name conflicts
can include dots to indicate a hierarchical structure


namespace Better1 
{
   namespace MyDataStructures
   {
      namespace MyArrays
      {
      }
   }
}

is the same as

namespace Better1.MyDataStructures.MyArrays 
{
}

Qualified names can be broken after a dot (.) if they are too long for a single line, as shown in the following example.



Default / Global Namespace

Any classes or code that is not explicitly added to an explicit namespace is contained in the global namespace



Everything is an object that derives from the root class System.Object


Microsoft.CSharp namespace ?

This namespace contains classes that support compilation and code generation using th C# language.


C# Highlights

Case sensitive
Statements are terminated with a semi-colon
Variables are declared after the data type
Curly brackets are used to delimit everything around all code blocks - more consistent
Allow unmanaged code to be called
No line continuation character
Less syntax - short and to the point.
Has no implicit type conversion
Must add parentheses to subroutines manually
String concatenation is done using "+"
Less automatic formatting than VB.NET
Only supports late binding through Reflection
Does not support parameterized properties


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext