C# Frequently Asked Questions

The C# team posts answers to common questions

What's the difference between string and System.String?

C# defines a number of aliases for CLR types. They may be used interchangably, and even mixed together, e.g.

string x = new System.String(' ', 5);.

These are the aliases defined:

Alias CLR type
string System.String
sbyte System.SByte
byte System.Byte
short System.Int16
ushort System.UInt16
int System.Int32
uint System.UInt32
long System.Int64
ulong System.UInt64
char System.Char
float System.Single
double System.Double
bool System.Boolean
decimal System.Decimal

[Author: Jon Skeet]

Published Friday, March 12, 2004 12:20 AM by CSharpFAQ

Comments

 

Adam Weigert said:

Are these aliases just like aliasing a type in the using statement?

So in effect, I could create my own aliases that match VB.NET data types?

using Byte = System.Byte
using Short = System.Int16;
using Integer = System.Int32;
using Long = System.Int64;

Not saying that I would want to, but hey you could, right? :p
March 12, 2004 5:34 AM
 

Boris Letocha said:

I think that void is also System.Void, but it is not interchable in C#, isn't it?

March 12, 2004 8:44 AM
 

hai said:

bool System.Boolean
May 6, 2004 7:08 PM
 

Max said:

String s;
DateTime dt;

if (dt == null) // error, because DateTime is value type
if (s == null) // ok (because reference type?)
Response.Write(dt); // writes "01.01.0001 00:00:00"
Response.Write(s); // writes "", although s=null, why?
July 26, 2004 7:04 AM
 

Afinal, qual a diferença de string e String? - Rafael Silva said:

August 28, 2008 10:27 AM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker