hi!
Are you a .NET programmer?
If so, try to share your .NET programming skills.
Thank you
-Viswanath
Do you know...

Visual Studio.NET is richest among all the other developer IDEs

.NET Chunks

         In general, a method is block of code that helps in performing a functionality. Basically a method looks as follows:
               [modifier] Method_name(Parameters of method){....}
        The modifier can be either an access sepecifier (like public , private etc.) or keywords such as static. The return type may be a value type or a reference type. The parameters are the variables whose scope is local with respect to the given method. These parameters add dynamic functionality to the code written under the method. The methods under the class may be static or non-static.
 Eg: class Hello
{
public int Met(int a,int b)
{
return a*b;
}
public static string Met1(string s)
{
return "Hello"+s;
}
static void Main()
{
Hello h=new Hello();
Console.WriteLine(h.Met(10,2));
Console.WriteLine(Met1("C#"));
}
}
In general sense 'abstraction' mainly means presenting complex scenarios in a simpler fashion. And this could be achieved by creating some simpler interfaces to the complex scenarios. By creating such interfaces it is quiet evident that we trying to hide the complexity of the complex scenarios using the concept of abstraction.

In Object Oriented programming this concept of abstraction is implemented using methods that we create under a class. For example, consider a simple sort() of the Array class under System namespace. To sort a list of array elements we just need to call the sort() using the Array class.(Array.sort(arr_name)). By writing a single line of code we are able to perform complex functionality of sorting. But under the definition of sort() complex sorting algorithms are used which are hidden from the programmer. So the entire complex code for sort() is abstracted and is presented just as a simple method and this simple sort() becomes an interface for the user to perform sorting of array elements.

Eg: class Abs
{
public static void gcd(int a , int b)
{
if(a
{
int c=b%a;
if(c==0)
{
console.WriteLine(a); return;
}
int d=a%c;
if(d==0)
{
console.WriteLine(c); return;
}
...................;
}
}}

        In the above class 'Abs', we defined a static method gcd() which performs gcd of 2 numbers. Writing this method  is complex and time consuming  for the programmer. To avoid this, we can allow programmer to directly call the gcd() under any class and use it-shown as follows:
class Test
{
static void Main()
{
Abs.gcd(3,4);
}
}
        So we are abstacting the method gcd() from the programmer. That means we are allowing him to directly consume a method without showing him the definition for that method.
        The members of the class (methods, properties, variables etc.) may be classified into two types: static and non-static members. There should be some means to access the class members to perform a functionality.


        To access the non-static (or instance) members of the class within the same class or outside the class, we need to take permission from that class. To take permission from the class we need to create a copy of that class which is mostly referred as an object.
Eg:   class Test1
         {
           public int a=10; //non-static member
           static void Main()
           {
             Test1 t1=new Test1();
              Console.WriteLine(t1.a); //To access non-static member 'a' within same class
                                                    // 'Test1' where it is defined requires object 't1'
                                                    //of that class.
            }                                     
          }


Eg:  class Test2

       {
       static void Main()

        {
         Test1 t1=new Test1();
          Console.WriteLine(t1.a); //To access non-static member 'a'  of class 'Test1' from class
                                                //Test2 also requires object 't1' of the class 'Test1'.
         }
       }


        To access the static members of the class within the same class, we can directly refer them. But to access the static members outside the class we need to use that class name under which they are defined to refer them.


Eg:  class Test3
        {
          public static int b=20; //static member
          static void Main()
           {
             Console.WriteLine(b);// static member 'b' defined under class 'Test3' is directly
                                               // referred, no object of 'Test3' required.
           }
         }


Eg:  class Test4
        {
         static void Main()
           {
            Console.WriteLine(Test3.b); //static member 'b' of class 'Test3' is consumed under class
                                                        // 'Test4' by referring it with class name 'Test3' where it is
                                                        //defined
            }
         }
This principle of OOP mainly says that whatever be the code (methods, properties, variables etc.) written to develop an app should be wrapped into a container called as CLASS. This helps in providing security to the code which is lacking in procedural languages.


Eg: class Hello
      {
        ..........;    //Encapsulated class content
      }
        I think most of the programmers come from C platform and many others come from other procedural or structural language platforms. After mastering C or any other structural languages, most of us might have thought about the following two major flaws of procedural programming:
-In procedural languages like C we are exposing our piece of code to externals (main() since it is also a user defined function) without setting any permissions. So, there is lack of security (code access security) to the code that we write for procedural languages like C. For example, if we are defining a function in C, there is no restriction to call that function at any point of time under main().
 -In procedural languages like C we can define 'n' number of functions under a given program (say one.C). Now suppose that we are developing another program that should contain similar functions which are defined under one.C and the new program name is two.C. Though the functions defined in one.C are similar to the functions that are to be defined under two.C, we cannot consume these functions of one.C in two.C. So, there is no scope for reusability.

        Due to the lack of these two major features code access security and reusability in procedural languages, Object-Oriented Programming (OOP) came into picture.

       The problem of code access security is rectified by the concept of ENCAPSULATION in OOP and the problem of reusability is rectified by the concept of INHERITANCE in OOP. The other two major features apart from encapsulation and inheritance are Abstraction and Polymorphism which add some weight to the OOP.
        Its quiet simple creating and executing a C# app using VS.NET. I reckon one of the major reasons behind this is its user friendly GUI and the other reasons may be like intellisense, pre-written lines of code, code snippets and so on......

        To start writing a C# app we need to do the following:
Open VS.NET-->File menu-->new project-->choosing a template (as if now console app); choosing a framework version we want to work with-->click ok. As soon as we click ok, the created file will be opened and within the file we will find the following:

1.The set of namespaces that are frequently used and that are imported using 'using' statement.
2.Current project's namespace which is created automatically.
3.Current Class under the current project's namespace and a Main() under the current class, which are also created automatically.

        So now we can directly write our code for C# app within the Main() of the current class as following:   Console.WriteLine("first C# app");

        Now we can run the current C# app by using Debug option which will build and then run the C# app. To debug we need to press F5 or ctrl+F5. This will output the result in a console window.


        I think its quiet evident how VS.NET makes the development of a .NET app so simple. Instead of writing 8 lines of code we just wrote a single line of code and it (single line of code) can be executed by pressing a single key (F5).

        Compilation and execution of a C# app written in a notepad can be done using a command prompt but not VS.NET.

        It is recommended not to use windows command prompt (cmd). Instead of that we can use ” Visual Studio command prompt” which is a free tool available along with .NET framework.

        To know the reason, type CSC (C# compiler) within your windows cmd prompt. You will get the assistance as “csc is not recognized……….”, since no path is set to C# compiler. So we need to explicitly set path to C# compiler (like how we set path to java compiler) to compile and run C# app in windows cmd prompt, but why to do so when Microsoft provides us with a tool (VS cmd prompt) which has an ability to recognize the C# compiler or any .NET compatible language compilers.

        So, directly go to VS cmd prompt which is present within VS tools from Start-->MS VS 2008/2005. Now go to your current working directory by using cd command and type csc Basic.cs shown as follows:

       
        As soon as you press ‘enter’, Basic .exe file (called as assembly) will be generated - which includes compiled code (IL code) plus some other information (metadata + resources if any) regarding your file. This is shown as follows: (note: Type dir within the command line to view .exe file).


        Now type your C# filename within the VS cmd prompt to run or execute your app - shown as follows: (this will display the program output)

        To program the C# code it is not mandatory to use Visual Studio.NET. We can program it using some free tools such as notepad or any text editor. But it mandatory to install the .NET framework of required version.


        The following program is just a snap of simple C# console app which can be written in a notepad:

class Basic
{
static void Main()
{
System.Console.WriteLine("first C# app"); //like printf in C or cout in C++
}
}

        As OOP says "whatever you write should be enclosed within a container called as class to provide code access security - [ENCAPSULATION]", all the code above is written in a class named "Basic".
        As every program needs an entry point to get executed , the Main() is defined - which is the entry point to our program. OOP says "you cannot access the members of a class untill and unless you create an instance (called as object to that class) to that class". To avoid this we declare Main() as static. As static members doesn't require an obiect of a class to access them, the Main() which we defined above will get executed.
        The statement which we wrote within the Main() is helpful in displaying some content on the console (output window) . In this statement System is a namespace, Console is class within the System namespace and WriteLine is a static method within the Console class. All these are predefined and are present in BCLs. As WriteLine is a static method it also doesn't require the object of the 'Basic' class to access it.
        C# when developed is of version 1.0 (ECMA standardized). Later it is upgraded to 1.5 (ECMA standardized) and then to 2.0 (ECMA standardized) and now the current version is 3.0 (not yet standardized by ECMA). Though version 3.0 is not yet standardized by ECMA, Microsoft released the 4.0 version (Beta). So I reckon Microsoft is trying to add some more additional features to C# 3.0 as it a major release.
        C# is simple, strict, object-oriented, modern, CLS subscribed programming language developed by Anders Hejlsberg and team.

Why simple? C# takes most of its basic semantics from the previously evolved programming languages such as C. So if you are aware of the concepts (semantics) of data types, variables, control structures, functions, files…of C, then it would be easy for you to program a basic C# program. It has similar syntax as that of C++. So if you are a master of C++ then within no time you can master C# programming…..

Why strict?
-C# is case-sensitive. You cannot write int as iNt. (Compile time error).
-C# warns you not to declare a variable which is uninitialized. (Compile time warning).
-C# is strongly typed language. You cannot assign a string value to an integer type variable……

Why Modern? C# is a general purpose language. It supports lot of modern programming conventions which help in developing modern applications. E.g. Support to use of properties instead of variables which help in providing code access security.

Why Object-Oriented? C# subscribe to the principles of Object-Oriented Programming (OOP) such as Encapsulation, Abstraction, Inheritance, Polymorphism…

Why CLS subscribed? C# subscribes to the CLS (Common Language Specification). So it is going to generate the CIL (Common Intermediate Language) code after compilation which (CIL) is platform and language independent. Since C# subscribes to CLS it can be called as ‘C#.NET’.
        In general sense, an IDE (Integrated Development Environment) is a software development or a designer tool that
-increases the accuracy of developing the software apps
-reduces the time taken to develop a software app which ultimately leads to the faster app development.

        To develop a .NET app quickly and accurately Microsoft developed two IDEs:

1. Visual Studio.NET (VS.NET): This is mainly a developer IDE which enables
    -a developer to write code for windows or web…..apps in user friendly manner and
    -a designer to design a desktop or web app in user friendly manner but the design might not be so rich.
     Major basic Features: (exist from .NET 2.0)
    -It (VS.NET) understands the .NET framework (CLR+BCLs). I think you agree with me if you had already used .NET intellisense (drop downs). It is going to notify you which property or which method you need to use for a specific class and which class belong to which namespace and so on…
    -It understands the language compilers. This you would agree if you had already compiled a simple C# program without placing a semi-colon at the end of the statement….
    -It gives you inbuilt database support. This you would agree if you had created and managed a simple table from the server explorer window of VS.NET studio.

    There are lot of other features .But I think VS.NET is self-explanatory. Go – observe – design and code.

2. Expression Studio: This is exclusively a designer IDE which enables a designer to design very very…rich desktop and web apps. This also with same notion Go-Observe-Design.

Warning: But as a learner I just want to suggest you not to involve too much in VS.NET because it is going to kill your programming skills…this is for sure. If you are a real time developer...its fine….because you need to save time… Though you (learner or a developer) use it …just try to observe what is happening…..
With support of .NET platform, one can build quiet a number of applications that might be useful in our day-to-day life. The following is a list of some applications that can be build using .NET platform:


-Windows applications: Mostly used for desktop development. It involves development of Win Forms. E.g.: Any Software that we install within our desktop systems.

-Console Applications: Mostly used for creation of character user interface applications.
E.g.: DOS based applications

-Web Applications: Used for Web Development. These applications use ASP.NET technology for their development.
E.g.: Any webpage with extension .aspx.

-Windows and Web code libraries: Used for windows and web development. These include a set of user defined classes under a given user defined namespace. These are consumed by the programmers while developing windows and web apps. These are like user defined BCLs.
E.g.: A user defined class for defining the validations performed during a registration.
Note: Always first check in the.NET documentation for the required class before developing it. For example if you want to define a class that perform the validations for registration-first check whether any such class exists in the predefined .NET library and if present just consume it instead of creating it.

-Windows Services: These are set of services that run at the backend of windows OS. To get a clear idea I think it would be better if you check them manually as follows: Control panel -> Administrative tools -> Services (Windows Services). E.g.: Windows Audio service…

-XML Web Services: These help in the development of xml based distributed web applications. E.g.: WWW or P2P networks based applications.

-Smart Device Applications: These include applications that we build for Smart phones, pocket PCs etc.

And so on……..
        We already know that .NET Framework=CLR+BCLs (mainly). Like CLR, BCLs also play a very important role in the .NET app development. BCLs are predefined libraries developed by the Microsoft team that provide a set of functionalities (E.g. Interaction with databases, Interaction with Web etc.) to develop a .NET app. As the number of functionalities is at peak, the classes or interfaces associated with these functionalities are also at peak. So it is difficult for a user to consume them. For this purpose “Namespaces” were defined.

        A Namespace is nothing but a group of classes or interfaces that have similar functionalities. These namespaces are created in a hierarchical format. We can define even our own namespaces.
E.g.1. All classes or interfaces related to Web are grouped under “System.Web” namespace.
E.g.2. All classes or interfaces related to Database are grouped under “System.Data” namespace.
E.g.3. All classes that we create manually like first1, first2 etc. can be kept under a namespace like MyNameSpace (which is user defined namespace).

        This grouping of classes or interfaces under a namespace has following advantages:
-There is a possibility of having classes or interfaces with same name under different namespaces.
E.g. System.Console (predefined console class placed under predefined namespace) and MyNameSpace.Console (user defined console class placed under a user defined namespace).
-This grouping will help the developer to consume the classes in a user friendly manner as he will be able to find them in a hierarchy.

        The following diagram shows some basic functional groups of BCLs and then some namespaces associated with each functional group:






        The above mentioned namespaces are just a sample. There are still a number of other namespaces under BCLs that provide different other functionalities.
        In general sense, a language is a mixture of syntax and associated semantics that allows a programmer to develop required applications based on the logic. A language also consumes some predefined set of libraries that define some set of functionalities using which an application can be developed.


        As we already know that a .NET framework also includes some set of predefined libraries (BCLs) which can be utilized to develop a .NET app. These BCLs can be consumed by any language that subscribes to Common Language Specifications (CLS).

        Some of the languages that subscribe to CLS are:

-C# (includes features of C++ and Java)
-C++/CLI (CLS compliant implementation of C++)
-VB (From 7.0, CLS Compliant implementation of traditional VB)
-J# (CLS Compliant implementation of Java)
-F# (CLS Compliant implementation of Functional programming language ML)
-A# (CLS Compliant implementation of Ada)
-L#, Iron Lisp (CLS Compliant implementations of LISP)
-P# (CLS Compliant implementation of Prolog)
-Jscript.NET (CLS Compliant implementation of Jscript)
-Iron Python (CLS Compliant implementation of Python)
-Iron Ruby (CLS Compliant implementation of Ruby) and …………….

        Among these the VB and C# are developed by Microsoft and so they are most commonly used by the .NET programmers. The .NET SDK (Visual Studio) by default provides the compilers for C#, VB, C++. To work with any of the other languages a programmer needs to install the corresponding language compilers explicitly.
CLR (Common Language Runtime) mainly has the following common responsibilities:

-CLR's JIT (Just-in-Time) compiler is responsible for execution of the IL (Intermediate Language) code at the developer end while he is developing the .NET apps as well as at the client end when the .NET app is deployed.

-CLR provides automated memory management using Garbage collection. Due to this .NET memory management is isolated from .NET app developer i.e., CLR's garbage collector (GC) takes the responsibility in allocation as well as deallocation of memory for the created objects and there is no role of .NET developer in this activity(allocation and deallocation of memory).

-CLR's Common Type System (CTS) is responsible for maintaining the cross platform support for various types (data types)  of various .NET compatible languages.

-CLR's Exception Manager is responsible for runtime error handling (Exception handling).

        These are some common responsibilities os CLR. There are even some other responsibilities for CLR that are not discussed above, but will be discussed later.
Why versions??
The goal in application development is always the same: create the best possible software in the least amount of time. Yet the bar is continually raised, as demands from customers increase. To meet these demands, the platforms developers build on and the tools they use must get better and better—they must evolve.    -David Chappel, Chappel & Associates.

        I reckon, this software upgradation or enhancement or evolvement, whatever it is, can be called as versioning. The best example we can consider is .NET framework itself. Since its birth in 2002, .NET framework evolved version by version as follows:



The .NET framework architecture is mainly depicted as follows:




The architecture shows the following:

-.NET framework (CLR +BCLs)

-Operating System, in which the .NET framework and Visual Studio development tool can be installed . The OS can be either Windows or any other such as LINUX , UNIX, Solaris etc. for installing .NET framework since it is platform independent. But to install and use Visual Studio we need only Windows platform since Visual Studio tool is platform dependent.

-Technologies that subscribe to .NET Runtime
-Winforms, ASP.NET, ADO.NET (.NET framework 2.0 additions)
-WPF (Windows Presentation Foundation), WCF(Windows Communication Foundation), WF 
(Windows Workflow), CardSpace .(.NET framework 3.0 additions)
-LINQ (Language Integrated Query), ADO.NET Entity framework (.NET framework 3.5 additions).
   
-Languages that subscribe to .NET Runtime (C#, J#, VB etc.) i.e. those languages that are according to CLS (Common Language Specifications)
        One of the most fascinating features of .NET platform is its language independence. The major reasons behind its language independence are:

-Common Language Specifications (CLS): Every language that is targeting the CLR (i.e. .NET compatible languages such as C#, VB, J#, etc.) should generate the same type of CIL (Intermediate Language) code. Due to this specification the CIL code that is generated after compiling the C# source code can be consumed by VB and vice versa and this is applicable even for all the other .NET compatible languages.

-Common Type System (CTS): Every .NET compatible language defines its types based upon its individual standards. For example C# defines integer type as "int" whereas VB defines it as "integer". But for .NET Runtime int is an int, whether it may be C# type or VB type. This enables C# code to be consumed by VB and vice versa.

-Consumption of BCLs: All the BCLs are written in C#. But they are consumed by every .NET Compatible languages.

       All the above three features prove that .NET is really a definition for language independence.
       
       As soon as the developer completes developing the .NET app, he does the following:
- Compiles the app's source code with the help of corresponding language compiler to generate intermediate language code (IL code) [actually speaking when a .NET app's source code is compiled, an assembly (with .exe or .dll extension) is generated and IL code is part of that assembly. I will post about assembly in detail later].

-The assembly (which contains IL code) that is generated is carried to the client machine. As it is platform independent (cross platform support) it can be executed on the client machine. But prerequisites such as .NET framework (of required version) should be installed on the client machine prior to the execution of the assembly. At the client end the JIT (Just-in-time) compiler is responsible for the execution of the .NET app assembly. This JIT compiler is part of CLR, which is in turn a part of .NET framework

         This completes the journey of a NET app..In short it can be shown as follows:


        To develop a .NET app a developer first of all needs to install .NET runtime (CLR) on his machine along with BCLs. These two (CLR+BCLs) together may form a framework i.e. .NET framework. For developers feasibility Microsoft designed a developer environment or a tool i.e. Microsoft Visual Studio that includes inbuilt .NET framework. Just the developer needs to install this tool on his machine and start developing his apps. But once the developer starts using Visual studio, i. he needs to choose a language (C#, VB, J#, Pascal or any other 16 officially supported languages) that utilize the BCLs ii. he needs to choose the type of application (console, Windows, Web etc.) he needs to develop and start working out..

      Now the client (who utilizes the app developed by the developer), needs to install the .NET framework (required version) within his machine first to run the respective .NET App and then he can start consuming the app.

End .NET Chunks