BASIC TERMS

Following are the basic terms that we will use in C#:

using System;

This is an instruction to the C# compiler to tell it that we want to use things from the 
System namespace. A namespace is a place where particular names have meaning. 
We have namespaces in our conversations too, if I am using the " Football" 
namespace and I say “That team is really on fire” I'm saying something good. If I 
am using the "Firefighter" namespace I'm saying something less good. 
In the case of C# the System namespace is where lots of useful things are described. 
One of these useful things provided with C# is the Console object which will let me 
write things which will appear on the screen in front of the user. If I want to just refer 
to this as Console I have to tell the compiler I'm using the System namespace. This 
means that if I refer to something by a particular name the compiler will look in 
System to see if there is anything matching that name. We will use other namespaces 
later on.

static:

" We donot have to create an objest for a static method"

This keyword makes sure that the method which follows is always present, i.e. the 
word static in this context means "is part of the enclosing class and is always 
here". When we get to consider objects we will find that this little keyword has all 
kinds of interesting ramifications. But for now I'd be grateful if you'd just make sure 
that you put it here in order to make your programs work properly.

void:

A void is nothing. In programming terms the void keyword means that the method 
we are about to describe does not return anything of interest to us. The method will 
just do a job and then finish. In some cases we write methods which return a result 
(in fact we will use such a method later in the program). 
However, in order to stop someone else accidentally making use of the value 
returned by our Main method, we are explicitly stating that it returns nothing. This 
makes our programs safer, in that the compiler now knows that if someone tries to 
use the value returned by this method, this must be a mistake.

Main():

You choose the names of your methods to reflect what they are going to do for you. 
Except for Main. This method (and there must be one, and only one such method) is 
where your program starts running. When your program is loaded and run the first 
method given control is the one called Main. If you miss out the Main method the 
system quite literally does not know where to start. 

()

This is a pair of brackets enclosing nothing. This may sound stupid, but actually tells 
the compiler that the method Main has no parameters. A parameter to a method gives 
the method something to work on. When you define a method you can tell C# that it 
works on one or more things, for example sin(x) could work on a floating point 
value of angle x. We will cover methods in very great detail later in this document.

{

This is a brace. As the name implies, braces come in packs of two, i.e. for every open 
brace there must be a matching close. Braces allow programmers to lump pieces of 
program together. Such a lump of program is often called a block. A block can contain 
the declaration of variables used within it, followed by a sequence of program 
statements which are executed in order. In this case the braces enclose the working 
parts of the method Main.
When the compiler sees the matching close brace at the end it knows that it has reached 
the end of the method and can look for another (if any). The effects of an un-paired 
brace are invariably fatal....

double

By now you probably feel that you need a drink. But that is not what double means in 
this context. What it means is "double precision floating point number".
Our program needs to remember certain values as it runs. Notably it will read in values 
for the width and height of the windows and then calculate and print values for the 
glass area and wood length. C# calls the places where values are put variables. At the 
beginning of any block you can tell C# that you want to reserve some space to hold 
some data values. Each item can hold a particular kind of value. Essentially, C# can 
handle three types of data, floating point numbers, integer numbers and text (i.e. letters, 
digits and punctuation). The process of creating a variable is called declaring the 
variable.

The semicolon marks the end of the list of variable names, and also the end of that 
declaration statement. All statements in C# programs are separated by the ; character, 
this helps to keep the compiler on the right track.
The ; character is actually very important. It tells the compiler where a given statement 
ends. If the compiler does not find one of these where it expects to see one it will 
produce an error. You can equate these characters with the sprocket holes in film, they 
keep everything synchronised.

Console.

On the right of the equals we have the thing which is going to be assigned to 
widthString. In this case the result is going to be the string returned by the method 
ReadLine. This method is part of an object called Console which looks after the 
user input and output. The full stop (.) separates the object identifier from the method 
identifier.

ReadLine

This indicates that the ReadLine method is to be invoked. This asks the running 
program to dash off, do whatever statements there are in this method, and then come 
back. Methods are a way in which you can break up your program into a number of 
chunks, each of which has a particular job. They also mean that you only have to write 
a particular piece of code once, put it in a method, and then call that method whenever 
you want that particular job done. The C# system contains a number of built in 
methods to do things for our programs. ReadLine is one of these.
When this program runs the ReadLine method is invoked (or called). It will wait for 
the user to enter a line of text and press the Enter key. Whatever is typed in is then 
returned as a string by the ReadLine method. The result of the method call is placed in 
the widthString variable.  

Console.WriteLine

This is a call of a method, just like the ReadLine method, except that this one takes 
what it is given and then prints it out on the console.

(

This is the start of the parameters for this method call. We have seen these used in the 
calls of Parse and also ReadLine

//////////////////END OF THIS SESSION///////////////
//////////////////WORKING IN PROCESS//////////////
//////////////////KEEP VISITING THANK YOU/////////

No comments:

Post a Comment