Serving Information Simply

Sunday, 4 November 2012

Basic information about C sharp -Dot Net

Some of the questions that always need to know a c# learner before going for the programming in C#. So from today I will write only about c# basics and ahead I will try to bring good articles for the beginners so keep visiting...
let’s start now ......

1. What is .NET?
   It is a platform or technology from Microsoft based on .NET Framework
2. How languages differ from technology?
   In a language things get created from scratch while in a technology things are already available but need to assembled.
What is a framework?
-          A software that provides a set of libraries, a set of tools and some rules
-          Examples
o   MVC (Model-View-Controller) framework
o   Struts
o   Hibernate
o   spring
o   .NET Framework
o   Mono Framework
What are different frameworks for .NET Technology?
-          There are two frameworks available for .NET technology
o   .NET Framework from Microsoft
§  Proprietary
§  Works with Windows Only
§  Supports all possible language under .NET
o   Mono Framework from Novell
§  Open Source
§  Works with all operating systems
§  Supports few languages like C# and Ruby
Is C# Platform Independent?
-          No
-          Since Mono which runs C# on all platform is not from Microsoft
Why .NET?
-         Actually .Net provide cross-Language interoperability among many languages of choice
o   C#
o   VB
o   J#
o   C++
o   F#
o   Pythen.NET
o   Ruby.NET
o   Pascal.NET
o   COBOL.Net
o   Etc.
-          All languages get compiled into a common format called as MSIL (Microsoft Intermediate Language)
-          Only on software is enough to run application written in any .NET based language called as CLR (Common Language Runtime)
-          To make the interoperable programs they must follow CLS (Common Language Specifications) compliancy rules
-          All language share the common libraries and tools provided by special software called .NET Framework
o   .NET Framework software provides different versions of libraries
§  1.0
§  1.1
§  2.0
§  3.0
§  3.5
§  4.0
-          All languages share the Common Type System (CTS). It is set of classes and structures that get mapped by different language based on their size
o   System.Byte
o   System.Int16
o   System.Int32 à C# (int), VB (Integer)
o   System.Int64
o   System.Single à C# (float), VB(Single)
o   System.Double
o   System.Boolean
o   System.String
o   System.Object
-          Single IDE called Visual Studio for any kind of development using any language of choice
o   Versions of Visual Studio
§  2001
§  2003
§  2005
§  2008
§  2010
-          Any kind of development using language of choice
o   Console Application
o   Window Based
o   Web Base
o   Mobile Applications
o   Window Service
o   Web Service
-          Integration other third party technologies
o   AJAX
o   Web Service
o   Web 2.0
-          No more “DLL Hell”
-          All .NET language is Object Oriented
What is the location of frameworks?

C# as Programming Language
-          A programming language based on .NET Framework based on C and C++, with the power of Java and simplicity of Visual Basic
-          It is an object Oriented Language
-          Every program should have a class
-          Every executable program  (.exe) must have an entry point
o   public static void Main()
o   public static int Main()
o   public static void Main(string []args)
o   public static int Main(string []args)
-          File must be saved as .cs
Syntactical Rules of C#
-          All keywords must be lower case
-          All other items should start with capital letter
o   It is called as Pascal case
Hierarchy in .NET
Assembly or Dynamic Link Library (DLL) à Namespaces à Classes/Structures àField/Method etc.
MSCorlib.dll à System namespace à Console class à Write(),WriteLine()
Test Case
System.Console.WriteLine("Hello to C#");
Writing First C# (C-Sharp) Program
Class First
                public static void Main()
                                System.Console.WriteLine("Hello to C#");

Compile the program
-          Use compiler as CSC.EXE
o   CSC <programname>
CSC First.cs à First.exe
Running an executable file
Note: If CSC is not working then set the PATH
Look for your framework folder, copy the path, now the set path using DOS
SET PATH=%PATH%; C:\WINDOWS\Microsoft.NET\Framework\v3.5
Setting Path using My Computer à Properties à Advanced à Environmental Variables à System Variables à Path à Edit à Add your path after a semicolon
View contents of an MSIL file
      Use ILDASM (Intermediate Language De-Assembler) tool to view contents of an MSIL file
ILDASM <filename>
ILDASM First.exe
How C# programs execute
.cs à CSC à .exeà CLR à Code Verifier à Just-in-time (JIT) compiler à Native code à Execution

Importing the Namespaces
-          Use using keyword
using <namespacename>;
using System;
class First
        public static void Main()
                        Console.WriteLine("Hello to Using");

Creating Aliases to namespace and classes
-          Use the using keyword again
using <aliasname>=<namespace or class>;
//Creating an alias
using c=System.Console;
class First
                public static void Main()
                                c.WriteLine("Hello to Alias");

Using Visual Studio.NET IDE as RAD (Rapid Application Development) tool
-          Start the Visual Studio.NET 2008
-          Create a new project using Visual C# as language and Console Application as Template
-          Select the location and Type the Project Name as Sample
-          Use Ctrl+F5 to run the programs

1 comment:

  1. It is tough to get jobs in Australia, because laws say
    their country person get first pick. but if left over then you can get it.
    . must apply for work visa, then they tell u if you can work
    Also visit my web blog - migrate to australia