Click here to Skip to main content
15,909,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all first of all i am sorry because my first language is not english I want understand which one is faster C# data types or .net data types i try to understand by below code and i think .net data types is faster(is this correct?) i test this code both with x86 and x64 platform.
C#
StopWatch SW=new StopWatch();
SW.Start();
for (Int32 i = 0; i < 99999; i++)
{
    for (Int32 j = 0; j < 999; j++)
    {
        Int32 a = 37;
        Int32 b = 37;
        Double c = Math.Pow(a, b);
        String d = "abcde";
        String e = "abcde";
        String f = d + e;
    }
}
Console.WriteLine(SW.Elapsed.TotalMilliseconds);
SW.Stop();
Console.ReadKey();


and second code
C#
Stopwatch SW = new Stopwatch();
SW.Start();
for (int i = 0; i < 99999; i++)
{
    for (int j = 0; j < 999; j++)
    {
        int a = 37;
        int b = 37;
        double c = Math.Pow(a, b);
        string d = "abcde";
        string e = "abcde";
        string f = d + e;
    }
}
Console.WriteLine(SW.Elapsed.TotalMilliseconds);
SW.Stop();
Console.ReadKey();

in this link Difference Between Data Type in C# and Data Type in .NET[^] "said all data types are converted into .Net Data type"What does this mean?I think if this word is true so converting C# alias data types to .net data types it takes time and i tested this by above codes but i am not sure if anyone sure(not unsure) please answer me thanks a lot

What I have tried:

i trying in console and winform with visual studio and without it
Posted
Updated 6-Feb-20 6:53am
v4

There is no difference in terms of performance between c# keywords for built-in types, and .NET types. The compiler will compile all of them to their .NET version.
So, that does not make any difference, in terms of performance, whether you are using int or Int32.
 
Share this answer
 
v2
 
Share this answer
 
There's no such thing as "C# types" vs ".NET types". They are one in the same. The keywords for types you see in C# are just aliases for the .NET types.

For example, a C# int is a .NET Int32. There is no different between them at all because both names refer to the exact same type.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900