Data Types are the basic building block of any language.
A D V E R T I S E M E N T
Microsoft has tried
to standardise the data types in .NET framework by introducing a limited, fixed
set of types that can be used to represent almost anything in programming world.
C++ was very rich in data types, but that leads to confusion too. Especially, when
we write components that may be consumed by applications written in other platforms,
we have to make sure the types used are compatible with other platforms too!
NET types start from a clean slate. All .NET languages share the same types. So,
they are all compatible and no worries. This means, we can call C# code from VB.NET
and vice versa, without worrying about type conversions.
NET data types are either structures or classes, part of the System namespace. For
example, the following data types are implemented as struct in .NET:
Int16
Int32
Double
(String is implemented as a class in .NET.)
If you are not very familiar with struct and class, don't worry about it. We can just
use them as if they are simple data types.
Here is how we can declare variables of type Int, Double and String:
Int16 age, employee Number;
Double salary;
String name, address;
we can use any of the .NET data types directly in any .NET language - in C#, VB.NET
or xyz. NET. But in addition to the .NET types, each language provides a set of
primitive types, which map to the corresponding types in .NET class library. This is
why we may see some people use string and some others use String. There is no big
difference. string is a primitive data type in C# and String is the corresponding
class in .NET class library. The string in C# is mapped to the class in .NET class
library. So, whether we use string or String, there is no real difference.
Data Types in C# and the corresponding class/struct in .NET class library
The following list shows the list of data types available in C# and their corresponding
class/struct in .NET class library.
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords Data types in C# and .NET, system c#, c# c++, c# component, c# dotnet, vb c#, c# example,
convert c#, visual c#, data method, data controls, value data, c# control, vb data,
c# application, c# sample, system data, data form, c# form, csharp c#, custom c#,
use c#, format data, c# create