Console is a
predefined class under the base class Libraries which provides standard IO
functionality that can be performed on standard IO devises like - keyboard and
monitor. The class has a set of static method like- Write, WriteLine, ReadLine
etc.
Because the
method s are static we don’t required the object of class for Invoking them
what we needs only the name of the class.
System is a
“Namespace” which is a logical container of types. Logical containers are used
in two different cases.
- To group related items i.e. under base class library we have number of classes that performs related operation .To group all related classes they were put on the separate name spaces.
System.Runtime.Remoting.Channel.Tcp;
Importing a Namespace: - If
at all a class is defined under a Namespace must and should we need to refer
the class only with the help on name space in which it was present. This may be
a complication if we want to consume the class for multiple times. To overcome
the problem you can use the option importing on name space i.e. on the top of
the program if we write “using ”
within the class we can consume all classes under that Namespace without
prefixing it namespace again
Using System;
class UsingDemo
{
Static voidMain()
{
console.WriteLine(“Importing
a namespace”);
}
}
|
Data types-
Integer
type-
byte
|
System. Byte
|
0-255
|
short
|
System.short
|
-32768to32767
|
int
|
System.int
|
-2^31to 2^31-1
|
long
|
system.long
|
-2^63 to @^63-1
|
sbyte
|
system.sbyte
|
-128 to 127
|
ushort
|
system.ushort
|
0-65535
|
uint
|
system.uint
|
0-2^32-1
|
ulong
|
system.ulong
|
0-2^64-1
|
Decimal or
float types:-
float
|
System.single
|
4 bytes
|
double
|
System.double
|
8 bytes
|
decimal
|
System.decimal
|
16 bytes
|
Boolean
type:-
bool
|
System.boolean
|
true or false
|
Character
types:-
char
|
System.Char
|
2 byte
|
string
|
System.string
|
The size of char type has been increased to 2 bytes for
providing the support to Unicode characters i.e. all the languages other than
English which are represented with a Unicode value.
String is a variable length type which doesn’t
have any fixed size. Its size depends upon the value we assign to it.
Root Type:-
Object
|
System.object
|
Object type is
capable of storing any type of value in it like – Character, Integer, and
Float, Boolean etc. it is also variable length type.
[ <> ] [const][read only]<><><= value] [,…n]
int x;
int y = 100;
string
S1,S2,S3;
public const
float pi=3.14f;
double dd =
324.879;
public readonly
decimal d = 456.987m;
modifiers or
special keywords like- public , privet, static etc.
Note- the default
scope for member of a class in c# is privet.
A constant and
read only variable or same which cannot be modified after assign a value.
Every numerical value by defoult is considered as int and decimal value
is considered as double so to represent a float velue suffices the value f and
m for decimal value