Tuesday, 7 July 2015

C# Programming



C# was developed by Anders Hejlsberg

Why C# a widely used professional language?
  • It is a modern, general-purpose programming language
  • It is object oriented.
  • It is component oriented.
  • It is easy to learn.
  • It is a tructured language.
  • It produces efficient programs.
  • It can be compiled on a variety of computer platforms.
  • It is a part of .Net Framework.

few important features of C#:
 Boolean Conditions
 Automatic Garbage Collection
 Standard Library
 Assembly Versioning
 Properties and Events
 Delegates and Events Management
 Easy-to-use Generics
 Indexers

Visual C# Default Code Snippets / C# code shortcuts

By default the following code snippets are included in Visual Studio.
Name (or shortcut)DescriptionValid locations to insert snippet
#ifCreates a #if directive and a #endif directive.Anywhere.
#regionCreates a #region directive and a #endregion directive.Anywhere.
~Creates a destructor for the containing class.Inside a class.
attributeCreates a declaration for a class that derives from Attribute.Inside a namespace (including the global namespace), a class, or a struct.
checkedCreates a checked block.Inside a method, an indexer, a property accessor, or an event accessor.
classCreates a class declaration.Inside a namespace (including the global namespace), a class, or a struct.
ctorCreates a constructor for the containing class.Inside a class.
cwCreates a call to WriteLine.Inside a method, an indexer, a property accessor, or an event accessor.
doCreates a dowhile loop.Inside a method, an indexer, a property accessor, or an event accessor.
elseCreates an else block.Inside a method, an indexer, a property accessor, or an event accessor.
enumCreates an enum declaration.Inside a namespace (including the global namespace), a class, or a struct.
equalsCreates a method declaration that overrides the Equals method defined in the Object class.Inside a class or a struct.
exceptionCreates a declaration for a class that derives from an exception (Exception by default).Inside a namespace (including the global namespace), a class, or a struct.
forCreates a for loop.Inside a method, an indexer, a property accessor, or an event accessor.
foreachCreates a foreach loop.Inside a method, an indexer, a property accessor, or an event accessor.
forrCreates a for loop that decrements the loop variable after each iteration.Inside a method, an indexer, a property accessor, or an event accessor.
ifCreates an if block.Inside a method, an indexer, a property accessor, or an event accessor.
indexerCreates an indexer declaration.Inside a class or a struct.
interfaceCreates an interface declaration.Inside a namespace (including the global namespace), a class, or a struct.
invokeCreates a block that safely invokes an event.Inside a method, an indexer, a property accessor, or an event accessor.
iteratorCreates an iterator.Inside a class or a struct.
iterindexCreates a "named" iterator and indexer pair by using a nested class.Inside a class or a struct.
lockCreates a lock block.Inside a method, an indexer, a property accessor, or an event accessor.
mboxCreates a call to MessageBox.Show. You may have to add a reference to System.Windows.Forms.dll.Inside a method, an indexer, a property accessor, or an event accessor.
namespaceCreates a namespace declaration.Inside a namespace (including the global namespace).
propCreates an auto-implemented property declaration.Inside a class or a struct.
ropfullCreates a property declaration with get and set accessors.Inside a class or a struct.
propgCreates a read-only auto-implemented property with a private "set" accessor.Inside a class or a struct.
simCreates a staticint Main method declaration.Inside a class or a struct.
structCreates a struct declaration.Inside a namespace (including the global namespace), a class, or a struct.
svmCreates a staticvoid Main method declaration.Inside a class or a struct.
switchCreates a switch block.Inside a method, an indexer, a property accessor, or an event accessor.
tryCreates a try-catch block.Inside a method, an indexer, a property accessor, or an event accessor.
tryfCreates a try-finally block.Inside a method, an indexer, a property accessor, or an event accessor.
uncheckedCreates an unchecked block.Inside a method, an indexer, a property accessor, or an event accessor.
unsafeCreates an unsafe block.Inside a method, an indexer, a property accessor, or an event accessor.
usingCreates a using directive.Inside a namespace (including the global namespace).
whileCreates a while loop.Inside a method, an indexer, a property accessor, or an event accessor.