Wednesday, 19 September 2012

Starting With C# Fundamentals - 1

Compilers

Lets know from you only what is Compiler ? Do you have some idea about it ? Anything you have heard or have some knowledge about it ? if Yes , Then its good and 
If no, then not to worry i am here to tell YOU....

From the help of example i will explain you :

Think that if you hold a page of delicious dish recipe but it is written in other language which not understandable by you.... what will you do ? 
Then you will have to Translate that other Language with the help of Translator into the Language understandable by you(English or any other)..... 

Similarly Codes written in different programming language ,first have to be converted into Machine Language understandable by computer which is translated by Compiler.

Compiler is a special program and also follows I-P-O(Input-Process-Output) Cycle . It takes the Code from the user as input and then the code is processed and gets converted in machine Language and then that coding is executed by the compiler.

Each programming languages has its own compiler. for ex- JAVA has Java compiler , C# has C# compiler.


Namespaces

Namespaces acts as container which contains group of assemblies , classes.For ex- Folder(namespaces) contains File(classes,assemblies).

Namespaces are the way in which C# extracts the .NET library classes.

using System;// System is a namespace
class sample
{
public static void Main()
{

Console.WriteLine("Hello");
}
}


In this example above, System is the Namespace where Console class is located.

  • A class in a namespace can be accessed by using the Dot(.) operator in C#. For Ex-
    • WriteLine Method is accessed by using the DOT(.) operator.
  • Here Console is a class and the WriteLine Is the Method.
  • using directive is used to import the namespace System into the program.
IN THE ABOVE EXAMPLE:-

When The compiler will parse the Console.WriteLine method , compiler will understand that the method is undefined. Then it will search for the namespaces in the program which has using directive and upon finding it will compile the code without any Error. 



Some Tips:

1. C# is a case sensitive Language.
  • using directive will written as shown above.
  • System will also be written as same as above.
  • Console.WriteLine will be also written as above.
  • class will be also be written as above.
  • Main,public will also be written as above.


2. You can add comment by using // as above anywhere in the           program.



Variables

So, Do you have any idea about what is a variable ? 

Not to worry I am here to tell you Friends.....

A variable is an identifier that denotes a storage location used to store a data value.

While creating a program you might need to store values , for that you need variables.

For example-You are creating a program to add two numbers and display the sum as a result.... for that you have temporarily store the numbers in the variables and then add these numbers.

Basically, Variable is a location that has name and is temporarily used to store the values. The Value can be Integer, characters or a Decimal value.



A variable name must be declared by specifying the data type as prefix.




Data Type defines the type of data that can be stored in a variable.


For example- A variable Contact NO. will ideally store the Integer.

C# provides various Built-In Data types. Built-In Data types are predefined data types that can be directly used in the programs to declare the variables.



-> C# also provides user-defined data type such as classes(explained before), structures , Arrays, Delegates and Interfaces(will study in subsequent chapters).



Types of Data Type

1.Value type
2.Reference Type

Value Type directly contains the value.
Char , int and float are the examples of the Value Type Variables.
For ex- When You declare an char variable ,system allocates the memory to store the character value in it.

Reference type-The Reference type variables contains the reference or address of the data stored in the memory.


Declaration Of Variables:-

int count;
char c,d,e,f;
double pi;

-> Variables are separated by commas means you can declare as     
   many variables with same data type by separating with commas   
   and ending with semicolon. For ex- 
   

   int addition,value,minus,multiply......,himanshu;

Initialization of Variables

A variable must be given value after it has been declared but before it is used in the expression.

for ex-

int x;
x=100;

    OR
int x=100;

char cc='X';    // If you will use a character data type , then    
               //  while inserting value, you have use single 
              //   quotes as shown in the example.




string str;
str="Anything";

OR                        // if you will use a string data type,  
                         //  then while inserting value , you                      
                        //   have use double quotes as shown in  
                       //    example

string str="Anything"; 


Constant Variables

The variables whose value does not change during the execution of the program are know as Constants.
For ex- Number of student in a class in a program may not change during the execution of the program.

const keyword is used to make the variable Constant.



example-
const int Rows=10;
const int Num=11;



const int Peace; // is illegal.
Peace=1;            //  By definition, a constant cannot have 
                      //   its value changed later.
        
Advantages
1.They make our program easy to understand.
2.They make our program easy to modify.

Note:
After declaration of constants, they should not be assigned any other values.



.........................To be Continued

Thank You 
Himanshu Chawla
himanshuchawla4393@gmail.com








Tuesday, 11 September 2012

Introduction To .NET Framework - 1

In My previous Post i have Explained some part Of C# intro. and Now I will explain You .NET Framework (Used in Previous Post)




What Is .NET Framework ?
-> .NET Framework is a software Framework Developed By Microsoft that primarily runs on Microsoft Windows(ex- Windows XP, Windows 7).  

-> .NET Framework provides tools and technologies you need to build Networked Applications as well as Distributed and Web Applications.

-> .NET Provides Language Interoperability (each language can use written in other language) across several other programming languages.

-> It Consists of Dynamic Libraries that are required by Microsoft Windows to run the program written in the language C#,vb.net etc.



Different Versions of .NET Framework:-


Versions
Release Date
1.0
February 2002
1.1
April 2003
2.0
November 2005
3.0
November 2006
3.5
November 2007
4.0
April 2010
4.5
August 2012






Features of .NET Framework:-

1.Interoperability- .NET provides support for Interoperability . It Doesn't means that program written in a language can be used by other language. To Enable a program to be used by other language,it must be created according to the rules CLS(Common Language Specifications).

2.Base Class Library- It is a Common Language Infrastructure(CLI) standard Library available to all CLI Languages. Base Class Library is included in CLI in order to encapsulate a large number of common functions such as, file reading and writing , database Manipulation,graphic rendering and XML document Manipulation . The .NET Framework is being the First Implementation of CLI as well as origin of Base Class Library.







3.Common Language Runtime- It is a virtual Machine Component of .NET Framework and is responsible for managing the execution of .NET Programs. The CLR Provides Additional Services such as Memory management , type Safety, Garbage Collection , Thread Management and Exception Handling. All The Programs regardless of programming language are executed by the CLR. CLR is common to all versions .NET Framework.

4.Security- The Design addresses Some Of the Vulnerabilities(Buffer Overflows). Additionally , .NET Framework provides a Common Security Models to all Applications.
  

Different Types Of Application That Can Developed in .NET :-

1.Web Applications
2.Windows Applications
3.Console Applications
4.Web Services
5.Mobile Applications

Class Library

The .NET Framework Library Includes a Huge Collection of reusable classes , interfaces and value types that are used in the development process and it also provide access to system functionality.
The .NET Framework class Library is divided into Namespaces and has a Hierarchical tree structure.
The .NET Framework classes are fully object oriented and easy to use in program Developments. 


Memory Management 

The .NET Framework CLR(Common Language Runtime) frees the burden of managing Memory . Memory is allocated to objects of .NET types
from the managed heap,which is a pool memory managed by CLR. As Long as reference to an objects exists ,the objects in considered to be in use and when there is no reference to an object and it cannot be reached or used, it becomes Garbage.
.NET Framework has garbage collector which runs on separate Thread , that enumerates all the unusable objects and takes back the memory allocated to them.



To be Continued.................................... 

Monday, 10 September 2012

Introduction To C# - 1

What is C# ?
-> Its a language Developed by Microsoft Corporation, USA.
-> C# is Fully Object Oriented Language Like Java .
-> It is Designed To Support .NET Framework.
-> It is Derived From C and C++ Languages.
-> It is only Language Designed For .NET Framework.
-> Major Part of .NET Framework are actually coded in C#.

Why was C# invented ?
Because Sun wouldn't allow Microsoft to make any changes in JAVA.
Microsoft had a product Visual J++ but Changes made upset Sun and so it came to a Halt.

......................

To be Continued.......

First Blog

This Is my First Blog And Today itself i have learned how to use Blogger ...... So , I am here to Explore my Knowledge about C# ...... I am Student and Still learning C# and .NET Technology ... I don't know much about C# but i am learning it.
So , I will be Explaining C# Components and Every Important Point in it. As I am Learning it ,so if i make a mistake Then please Post your Comment Regarding that Mistake.



Thank You
Himanshu Chawla


Email ID- himanshuchawla4393@gmail.com