What is the Data Type how to declare datatype in Asp.net with C#
Data Type in C# with ASP.Net :
Basic Introduction of C#
Data type, In this post you
will learn what is Data
type C# and how many data type in C#. There are many types of C# data types(which type of data), according to their sizes and storing
capacities and stringent basically 2 type we discus here:
- Value Type:
- Reference Type:
Value Type data Type:
C# is a strongly
language. It means, that you can not use variable (which store value )
without data types. Data types tell the compiler(converter) that which type of
data is used in logic(program). Such as if you want to work in asp.net with
string value then you will assign string variable to work with.
C# has two types
of data types:
Reference Types:
Conceptually, a reference type represents a potentially
large piece of data that is passed around a program via a reference to that
data. Reference types tend to be more complex in nature than value types.
Reference types have three major traits of their own:
- Copy-by-reference semantics
- Identity equality semantics
- Heap memory allocation.
When an instance of a reference type is passed around in a
program, a reference (i.e. a small, unique identifier) to the instance’s data
is created. The data itself is not copied. Finally, when the copied
instance is edited, what’s actually being edited is the original data.
When two instances of a reference type are checked for
equality, the two instances are considered equal only if they both point to the
same piece of data (i.e. point to the same memory address).
In C#, reference types are allocated on
the heap rather than the stack (i.e. opposite of value
types). Depending on the usage of the type, this could affect
performance, although in most cases it’s not likely to matter.
It’s also worth noting that C# supports user-defined
reference types. These are called classes. Classes allow you
to define custom fields and methods on a reference type.
Value types:
Conceptually, a value type represents a very simple of data
(number like 123 or a character like P).
In C#, value types have three major traits.
A Value type data type stores copy the value whereas the Reference type data types stores the memory location of the value. C sharp provides many predefined for working with ASP.NET, but it also provide power to user that's user create user defined data type when user need .
A Value type data type stores copy the value whereas the Reference type data types stores the memory location of the value. C sharp provides many predefined for working with ASP.NET, but it also provide power to user that's user create user defined data type when user need .
When an instance of a value type is passed around in a
program, it is copied each time. When a
copy is edited, the original version does not change.
In C#, value types are allocated on the stack.
Deceleration of data:
<data
type><variable name>=<value>
here datatype refer
which type of data store in this variable.
variable name refer 'A
NAME OF MEMORY LOCATION where data is store .
value refer what is the
value which is store in this given variable
Example of DATA Type :
1. String
string1="parijat";
here string1 is a
variable which octane a string type (data type) value "parijat";
2. int number1=10;
here number1 is a
variable which canted a integer type value 10;
similarly we can defined
many type of data and then perform action Programming logic .
since we see that C sharp is not very typical its a very sample Programming language .
In next post we learn
how to make a sample program in asp.net with C# and some other logical
examples
Type
|
Range
|
Size
|
bool
|
true/false
|
1 byte
|
byte
|
-128 to
127
|
1 byte
|
sbyte
|
0 to 255
|
1 byte
|
char
|
unicode;
0×0000 to 0xFFFF
|
2 bytes
|
ushort
|
0 to
65535
|
2 bytes
|
short
|
-32768
to 32767
|
2 bytes
|
uint
|
0
to
4,294,967,295
|
4 bytes
|
int
|
-2,147,483,648
to
2,147,483,647
|
4 bytes
|
ulong
|
0
to
18,446,744,073,709,551,615
|
8 bytes
|
long
|
–9,223,372,036,854,775,808
to 9,223,372,036,854,775,807
|
8 bytes
|
float
|
-3.4 ×
1038
to
3.4 ×
1038
|
4 bytes
|
double
|
±5.0 ×
10−324
to
±1.7 ×
10308
|
8 bytes
|
decimal
|
(-7.9 x
1028 to 7.9 x 1028) / (100 to 28)
|
16 bytes
|
struct
|
varies /
user-defined
|
varies /
user-defined
|