The following are the topics to be covered in this article:
- Welcome to C#
- Working with variables, operators and expressions
- Understanding your first C# program
Welcome to C#
C# is a powerful language that is generally called a Component Oriented Language. Now we have heard of Object Oriented Languages, but what is a Component Oriented Language? Though the difference is unclear and thin, the reason why this new concept has become associated with C# is that a new technique was to be introduced that would develop software combining some pre-existing features (OOP) and welcoming some new components. Some of the components are:
- Properties
- Methods
- Events
- Attributes (Metadata-Data about Data)
- Assemblies/Packages
Another major characteristic is the introduction of Separation Of Concerns (SOC) and the Service Oriented Architecture (SOA). SOC is Separation Of Concerns via partial classes in C#.
Versions in C#
The following are the versions so far. The data is from C# Indepth. Please visit or follow the book to learn more about the various versions.
- C# version 1
- C# version 2: As said previously, in this version, Generics, Nullable types(), anonynous types and Iterators(blocks) were introduced.
- C# version 3: As said previously, implicit typing, object and collection initializers, anonymous types, automatic properties, lambda expressions, extension methods, query expressions were introduced.
- C# version 4: As said previously, dynamic typing, optional parameters, named arguments and generic variance were introduced.
- C# version 5: As said previously, asynchronous functions, caller info attributes, a tweak to foreach (one of the examples is Parallel.Foreach (with Lambda expression)) and iteration variable capture were introduced. Caller info attributes is a very new concept and an interesting one too. These attributes track information about the calling methods/properties and many more.
A small incident to share, I always wondered why C Sharp?? Is it a kind of successor to C++ or what? I always wondered and I feel many beginner developers would be wondering. Thanks to Wiki the datawarehouse for every bit of concept in the world for letting me understand why? Without any delay, straight from the WIKI,
The name "C sharp" was inspired by musical notation where a sharp indicates that the written note should be made a semitone higher in pitch. The sharp symbol also resembles a ligature of four "+" symbols that thus implies that it is an increment of C++.
Now let's get along and start learning from the basics.
Camel and Pascal Case Notations
Every time a developer gets into these concepts, but sometimes beginners like me would wonder what these actually are. Camel case is used for naming fields whereas Pascal case is used for naming properties and function names. In Pascal case, the starting letters in the multiword name are capitalized whereas in Camel case except the very first letter is all capitals as in the following:
- Pascal Case: GetSumFromNumbers.
- Camel Case: getFirstNumber.
Working with Variables, Operators and Expressions
Before getting into the variables, let's get into what an identifier is. Identifiers are the names that are used to identify elements in the program. In C#, there are the following conventions to be followed:
- Only letters are allowed (it may be uppercase or lowercase), digits and underscore(_) characters are allowed.
- An identifier should always start with a letter.
For example, _getSum, GetSum, Get_sum are valid identifiers. Just to remember or keep in mind everytime that C# is case sensitive so getSum and GetSum are different and provide different meanings. Keywords, there are many keywords that are predefined in C#, for more info on the keywords, use the following link: C# keywords Now let's get back to our topic of discussion, variables. A variable is a location with memory or storage location that stores/holds a value. A variable in a program holds a unique name, its like madatory to provide it a unique name. A variable holds temporary information. A variable is used to get the value that it holds after assigning. In the following I specify the naming conventions to be followed when declaring variables specified by the Microsoft .NET team:
- Underscores are advised not to be used.
- Variables names that differ only in capitalization should be avoided. Like, abcTest or AbcTest used in the same file and at the same time. This would also mean identifiers with the same name and different case should be avoided.
- It is advised to start the name with a lowercase. This would be consistent throughout since it would lead to easy mantenance.
- Camel case notations should be used, for example, abcTest, myVariable, as such.
Declaring Variables is easy and simple. Usually the keyword var is used when the type is to be implicitly decided. If any datatype is already used during the declaration of the vriable, then it is explicitly typed.
- var setAge; //implicitly typed
- int setAge; //explicitly typed
- setAge = 45; //values assigned




Former memberPosted Jun 21, 2017, 6:15 AM
If possible please give me a example of Pascal Case & Camel Case coding for a whole class where where class will have some private and public data member, few public property and few public functions.
Gowtham RajamanickamPosted Mar 14, 2015, 4:49 AM
good one..