Content below is a transcript of the following discussion http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string All the content contributed to Stack Overflow, Stack Overflow Meta, Server Fault, and Super User is cc-wiki (aka cc-by-sa) licensed, intended to be shared and remixed. (under cc-wiki with attribution required)
The answer is pretty simple. All are the same. First one is C# datatype and other is CLR dataType.
When we compiled C# code, C# datatype converts to CLR data type. So you have freedom to use any one of them. There is no performance difference.
(by Jon Skeet) As others have noted, string is an alias for System.String. They compile to the same code, so at execution time there is no difference whatsoever. This is just one of the aliases in C#. The complete list is:
string
System.String
object: System.Object string: System.String bool: System.Boolean byte: System.Byte sbyte: System.SByte short: System.Int16 ushort: System.UInt16 int: System.Int32 uint: System.UInt32 long: System.Int64 ulong: System.UInt64 float: System.Single double: System.Double decimal: System.Decimal char: System.Char
Apart from string, object, the aliases are all to value types. decimal is a value type, but not a primitive type in the CLR. The only primitive type which doesn’t have an alias is System.IntPtr.
object
decimal
System.IntPtr
In the spec, the value type aliases are known as “simple types”. Literals can be used for constant values of every simple type; no other value types have literal forms available. (Compare this with VB, which allows DateTime literals, and has an alias for it too.)
DateTime
There is one circumstance in which you have to use the aliases: when explicitly specifying an enum’s underlying type. For instance:
public enum Foo : UInt32 {} // Invalid public enum Bar : uint {} // Valid
public enum Foo : UInt32 {} // Invalid
public enum Bar : uint {} // Valid
(Luke Foust says) The best answer I have ever heard about using the provided type aliases in C# comes from Jeffrey Richter in his book CLR Via C#. Here are his 3 reasons:
BinaryReader br = new BinaryReader(...); float val = br.ReadSingle(); // Ok, but feels unnatural Single val = br.ReadSingle(); // OK and feels good
BinaryReader br = new BinaryReader(...);
float val = br.ReadSingle(); // Ok, but feels unnatural
Single val = br.ReadSingle(); // OK and feels good
Naomi N edited Revision 10. Comment: Minor edit
Peter Geelen - MSFT edited Revision 7. Comment: All the content contributed to Stack Overflow, Stack Overflow Meta, Server Fault, and Super User is cc-wiki (aka cc-by-sa) licensed, intended to be shared and remixed
Naomi N edited Revision 6. Comment: Typo fix
Naomi N edited Revision 1. Comment: Content is taken from stackoverflow without a reference to it
Naomi N edited Original. Comment: Minor edit
So, the question is - do we consider this article to be a simple plagiarism? It is compiled from answers by several people in the stackoverflow question. The question itself and the discussion is quite interesting, but what rules should we follow by re-posting such content? Is it OK to re-post it? I see many interesting questions with answers on stackoverflow
All the content contributed to Stack Overflow, Stack Overflow Meta, Server Fault, and Super User is cc-wiki (aka cc-by-sa) licensed, intended to be shared and remixed.(under cc-wiki with attribution required)
See creativecommons.org/.../3.0 and
See blog.stackoverflow.com/.../attribution-required
I see. The last quote needs to be attributed also as well as the question itself. Also, this opens a door for simply transferring many good questions from that site into TechNet Wiki. Say, today I was researching a question of how to output DataRow into a dictionary and found the answer in stackoverflow. Also, I think other articles by this user need to be checked and appropriate credit need to be added or content deleted