Friday, January 6, 2012

Console application

Console applications means Word, Excel, notepad , etc. User typically interacts with a console application using only a keyboard and display screen.

First C# program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace helloworld
{
class Strong
{
static void Main(string[] args)
{
Console.WriteLine("hello world");
Console.ReadLine();

}
}
}
==>c# is case sensitive

==> whenever we create a project the IDE automatically add some common namespaces with the help of "using" statement .
that is, using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Namespace acts like a last name or surname to a class . that is to call this particular program we can use " hello world.strong" and thus it avoids confusion or ambiguity and organize classes.
Namespace will be whatever your project name is.
Namespace contains a group of code that can be called by c# programs.

==>static void main(string[] args)
In the case of a simple console application main() method is the first method to be executed. main function typically has access to the command arguments given to the program when it was executed.
main() is often called as "entry point". Every method must have a return type ,here it is void which means main() does not return a value.
Using static, main() can run on its own and it does not need an object for reference.

==> Every method also has a parameter list.

==> console.writeLine allows what we want to write in console window. console is a class in system namespace and writeLine is a method in console class. WriteLine also called as a method parameter because we are writing a string in ("") ,that is , (" hello world") for our console window.
ReadLine() accept no parameters.

==> classes and methods begin with "{" and ends with "}". Any statement within { } defines a block.

No comments:

Post a Comment