Friday, January 13, 2012

Variable Declaration

Variables are named "buckets" containing values in your computers memory .You can create buckets just the right size using dates and times,for strings,etc.

C# consist of the Boolean type and three numeric types - Integrals, Floating Point, Decimal, and Strings.
Integrals"- refers to the classification of types that include sbyte, byte, short, ushort, int, uint, long, ulong, and char.

Floating Point- refers to the float and double types.

String type - represents a string of characters.

Integral types

They are whole numbers, either signed or unsigned, and the char type(16 bits). The char type is a Unicode character

How to declare an integer

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

namespace declarevariable
{
class Program
{
static void Main(string[] args)
{
int x, y;
x = 6;
y = x + 4;
Console.WriteLine(y);
Console.ReadLine();
}
}
}
Output is 10.

Boolean Type
Boolean types are declared using the keyword, bool. They have two values: true or false.
eg: using System;

class Booleans
{
public static void Main()
{
bool white = true;
bool black = false;

Console.WriteLine("It is {0) that jasmine is white in color", white);
Console.WriteLine("The above statement is not {0}.", black);
}
}
output - It is true that jasmine is white in color
The above statement is not false.

Floating Point and Decimal Types

C# floating point type is either a float or double. They are used any time you need to represent a real number



The string Type - A string is a sequence of text characters.

C# Operators

C# provides a large set of operators, which are symbols that specify which operations to perform in an expression.



Left associativity means that operations are evaluated from left to right. Right associativity mean all operations occur from right to left, such as assignment operators where everything to the right is evaluated before the result is placed into the variable on the left.

No comments:

Post a Comment