Tuesday, November 2, 2010

Learn c# easily lesson 4

lesson 1

       lesson 2

 lesson 3

                                Variables and Types

"Variables" are simply storage locations for data. You can place data into them and retrieve their contents as part of a C# expression. The interpretation of the data in a variable is controlled through "Types".
C# is a "Strongly Typed" language. Thus all operations on variables are performed with consideration of what the variable's "Type" is. There are rules that define what operations are legal in order to maintain the integrity of the data you put in a variable.
The C# simple types consist of the Boolean type and three numeric types - Integrals, Floating Point, Decimal, and String. The term "Integrals", which is defined in the C# Programming Language Specification, refers to the classification of types that include sbyte, byte, short, ushort, int, uint, long, ulong, and char. More details are available in the Integral Types section later in this lesson. The term "Floating Point" refers to the float and double types, which are discussed, along with the decimal type, in more detail in the Floating Point and Decimal Types section later in this lesson. The string type represents a string of characters and is discussed in The String Type section, later in this lesson. The next section introduces the boolean type.

The Boolean Type

Boolean types are declared using the keyword, bool. They have two values: true or false. In other languages, such as C and C++, boolean conditions can be satisfied where 0 means false and anything else means true. However, in C# the only values that satisfy a boolean condition is true and false, which are official keywords. Listing 2-1 shows one of many ways that boolean types can be used in a program.
Listing 2-1. Displaying Boolean Values: Boolean.cs
using System; class Booleans {    public static void Main()     {        bool content = true;        bool noContent = false;         Console.WriteLine("It is {0} that C# Station provides C# programming language content.", content);         Console.WriteLine("The statement above is not {0}.", noContent);     } }
In Listing 2-1, the boolean values are written to the console as a part of a sentence. The only legal values for the bool type are either true or false, as shown by the assignment of true to content and false tonoContent. When run, this program produces the following output:

    It is True that C# Station provides C# programming language content.

The statement above is not False.  
                 Visit next day ------>>>>>>                

1 comment:

  1. Very informative and impressive post you have written, this is quite interesting and i have went through it completely, an upgraded information is shared, keep sharing such valuable information. Hoarding Cleanup Ardmore

    ReplyDelete