Quantcast
Channel: What is the difference between String and string in C#? - Stack Overflow
Viewing all articles
Browse latest Browse all 69

Answer by tic for What is the difference between String and string in C#?

$
0
0

In case it's useful to really see there is no difference between string and System.String:

var method1 = typeof(MyClass).GetMethod("TestString1").GetMethodBody().GetILAsByteArray();var method2 = typeof(MyClass).GetMethod("TestString2").GetMethodBody().GetILAsByteArray();//...public string TestString1(){    string str = "Hello World!";    return str;}public string TestString2(){    String str = "Hello World!";    return str;}

Both produce exactly the same IL byte array:

[ 0, 114, 107, 0, 0, 112, 10, 6, 11, 43, 0, 7, 42 ]

Viewing all articles
Browse latest Browse all 69

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>