Friday, January 2, 2009

C#

hai buddies let us have a look into C#



C# is one of the popular object-oriented language introduced by MICROSOFT.C# contains features similar to c++ and java.C# is designed particularly to work with microsoft's .NET platform.C# is pronounced as C-Sharp.

.NET PLATFORM
The .NET platform is aimed at providing Internet users with Web-enabled interface for applications and computing devices such as mobile phones.It also provides developers the ability to create maodules,thereby increasing productivity.


C# COMPILER
A compiler is a special program that processes the statements within a particular programming language and converts them into machine language.Like everything else in the computer, the compiler also follows the Input-Output(I-P-O)cycle.It takes the programming language instructions as input.It processes these instructions to convert them to machine language.These instructions can be executed by the computer.This process of conversion is called compilation.For each programming language we have a different compiler.For example, C laguage uses a C-compiler,like wise java uses java compiler.In the same way C# uses a c-sharp compiler it is given by csccompiler.

Now let us see creating classes using C#




public class Hello
{
public static void Main(String[] args)
{
System.Console.WriteLine("Hello"\n);
}
}


The output of the above code will be "Hello".

The parts of the preciding code is explained below.

The Main() Function


The first line of the code that a C# compiler looks for in the source file compiled is the Main() function.This function is the entry point of the application.

The Main() is ideally used to create objects and invoke member functions.


The Class Keyword


The class keyword is used to declare a class.Keywords are reserved words that have as special meaning. Here, the class Keyword gefines the class Hello. The braces , known as delimiters, are used to indicate the start and end of a class body.

Example:


class Hello
{
...
}


The Class Name


The class Keyword is followed by the name of the class. In the preceeding example, "Hello" is the name of the class defined by using the class keyword.When you craete classes, you must consider the following naming conventions and rules.



class naming conventions in C#


Class names should follow certain naming conventions or guidelines A class name:
  • should be meaningul

  • should ideally be a noun

  • Can use either pascal or camel case


System.Console.WriteLine()


Console is a class that belongs to the system namespace. A namespace is a collection of classes. The system namesapces contains the method "WriteLine()",which displays the text on the screen.The Console class has other methods which are used for various input/output operations.The character(.) is used to access the function, writeLine(), which is coded in the Console class of the system namespace.

u can compile the code using

"VISUAL STUDIO COMMAND PROMPT" by typing csc Hello.cs
then ExecuteHello.exe
will give the output.

Thanks for viewing, and i hope its useful.


No comments:

Post a Comment