Object Oriented Concepts( OOp's)Threading in C# Synchronization in C# Inter - Thread Communications Enumerators Structures Abstract And Sealed Classes  Class Modifiers ActiveX Data ObjectOperator Overloading Parameter OverloadingData Types Accessing RegistryArrays & StringsReflectionStructures & EnumsFile HandlingMultiThreadingSecurityADO.NET Preprocessor DirectivesAssemblies & ManifestsException HandlingMiscellaneous(New)CollectionsASP.NETArticles by YPKManaged C++(New)


Why C#

C# ( pronounced as ‘C Sharp’ ) is the first language that has been designed from ground up with Internet in mind. It is a concise, clean, and modern language that combines the best features of many commonly used languages: VB, Java and C++. As truly said it combines the power of C++ with productivity of VB and elegance of Java.

C# is a new programming language introduced with .NET. With C#, developers who prefer the elegance and conciseness of C-style syntax, or might already be familiar with Java or C++, can quickly implement applications and components that support the .NET Framework. These are managed by the CLR, and interoperate with components and application written in other .NET aware languages.

The C and C++ developers face problems like: memory leaks, difficulty in writing multithreaded applications, static linking, illegal pointer references, overly complex multiple-inheritance rules, and so on. C# solves these problems. C# is better suited than any other language for an environment in which productivity, the Internet, and code-reuse are overriding concerns.


 History 

The history of C# begins early in 1970’s when C was invented in which UNIX was written. But C had some drawbacks. The power that C affords the programmer makes it easy for him to blunder. For example, it allows the programmer to directly allocate memory and permits him to deallocate this memory.

Then came C++ in 1980’s, who like its predecessor took the world by a storm. Despite it being object-oriented C++ had some problems. Veteran programmers often had problems migrating from C (structured) to C++ ( object-oriented ) because effective C++ programming requires a completely new mindset. 

Sun created Java. They were motivated with the World Wide Web. They sought a single environment that would target multiple platforms. Programs in Java are not compiled to machine code, but instead to an intermediate language or bytecode that can be executed on any computer equipped with a suitable interpreter program (The Java Runtime). 

Today, Microsoft unveils an alternative strategy for bringing the development and web worlds together and online with .NET. Because all .NET languages compile to a common bytecode, a developer can program in whichever language he wants and share his works with other developers using other .NET languages. 

Here comes in C#, developed by Anders Hejlsberg. This is a language designed for the .NET platform. C# promotes one-stop coding, the grouping of classes, interfaces and implementations together in one file so that developers can edit code more easily. C# handles objects in much the same way as Java i.e. via reference rather than via pointers. Another virtue of C# having been invented recently, is that it is intrinsically object-oriented and web-enabled.


 The C# Character Set
AlphabetsA, B, ….., Y, Z
a, b, ……, y, z
Digits0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special Symbols~ ‘ ! @ #% ^ & * ( ) _ - + =
 | \ { } [ ] : ;“ ‘ < > , . ? /


A character denotes any letter of the alphabet, digit or special symbol used to represent information. Following table shows the valid letters, numbers and special symbols allowed in C#:


 C# Keywords

C# contains a rich set of 76 reserved keywords. Keywords can be used as identifiers if prefaced by an @.

The keywords are:

abstractasbasebool
breakbytecasecatch
charcheckedclassconst
continuedecimaldefaultdelegate
dodoubleelseenum
eventexplicitexternfalse
finallyfixedfloat for
foreachgotoifimplicit
inintinterfaceinternal
islocklongnamespace
newnullobjectoperator
outoverrideparamsprivate
protectedpublicreadonlyref
returnsbytesealedshort
sizeofstackallocstaticstring
structswitchthisthrow
truetrytypeofuint
ulonguncheckedunsafeushort
usingvirtualvoidwhile

Many of these are surely not new to Java and C/C++ programmers

A few additional points to note about operators: -

  1. % ( known as the modulus operator ) gives the remainder and works on floats or reals too.

  2. is and typeof are used to find the type of an object at run-time.

  3. checked and unchecked are used to control how the compiler deals with overflow conditions in arithmetic calculations.