Florida .NET User Groups
Florida .NET User Groups  Status: Not logged in

Hot News
Skip Navigation Links

Our Stuff
Skip Navigation Links

Skip Navigation Links

Skip Navigation Links

Active Jobs: 9

C#: c# "string" versus .NET "String"
From: Wayne Erfling 9/13/2006 9:33:06 PM
I'm just getting more hands-on with asp.net / c# after leading a team since 2003.

I can't find any articles describing when the String class is used in asp.net versus when the c# "string" data type is used.

In an example in an early chapter of one book, "string" and "String" and intermingled with no explanation of what convention is being used to choose between them.

I also can't find any articles on the subject after an hour of searching.

Has Microsoft document their convention of when to use "string" versus "String" ?

I certainly don't want to write code by trying one or the other and then wait for errors so I know when to switch to the other one.

I'm an experienced IT professional, I understand case and classes, etc... All I'm trying to understand is when String and string are typically used so that I won't have to struggle with this too often.


From: Mayuri Lahane 1/18/2019 3:38:53 AM
In C#, string is an alias for the String class in .NET framework. In fact, every C# type has an equivalent in .NET. As another example, short and int in C# map to Int16 and Int32 in .NET.

So, technically there is no difference between string and String, but it is common practice to declare a variable using C# keywords. I’ve hardly seen anyone declaring an integer with Int32!

The only tiny difference is that if you use the String class, you need to import the System namespace on top of your file, whereas you don’t have to do this when using the string keyword.

C#: c# "string" versus .NET "String"


Copyright © 2001 - 2020 Florida .NET User Groups 
contact us
FlaDotNet is hosted by: http://www.appliedi.net