string
is an alias in C# for System.String
.
So technically, there is no difference. It’s like int
vs. System.Int32
.
As far as guidelines, it’s generally recommended to use string
any time you’re referring to an object.
e.g.
string place = "world";
Likewise, I think it’s generally recommended to use String
if you need to refer specifically to the class.
e.g.
string greet = String.Format("Hello {0}!", place);
This is the style that Microsoft tends to use in their examples.
It appears that the guidance in this area may have changed, as StyleCop now enforces the use of the C# specific aliases.
Related Posts:
- What’s the @ in front of a string in C#?
- Best way to repeat a character in C#
- How can I convert String to Int?
- What is a singleton in C#?
- My C# application is returning 0xE0434352 to Windows Task Scheduler but it is not crashing
- C# Set collection?
- Why is Dictionary preferred over Hashtable in C#?
- Does anyone still use [goto] in C# and if so why?
- How does the “Using” statement translate from C# to VB?
- What is the best way to parse html in C#? [closed]
- Best C# API to create PDF
- C# cannot convert method to non delegate type
- What is the difference between const and readonly in C#?
- Pass Method as Parameter using C#
- ArrayList vs List<> in C#
- How to solve ‘…is a ‘type’, which is not valid in the given context’? (C#)
- Calling the base constructor in C#
- String was not recognized as a valid DateTime ” format dd/MM/yyyy”
- How to empty a list in C#?
- Substring index and length must refer to a location within the string
- How to open an Excel file in C#?
- What is a method group in C#?
- How to convert UTF-8 byte[] to string
- .NET String.Format() to add commas in thousands place for a number
- How do I save a stream to a file in C#?
- Print Pdf in C#
- Can a Byte[] Array be written to a file in C#?
- What is a quick way to force CRLF in C# / .NET?
- How to create a new object instance from a Type
- Creating a List of Lists in C#
- Unrecognized escape sequence for path string containing backslashes
- C# int to byte[]
- What’s the difference between .NET Core, .NET Framework, and Xamarin?
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- No connection could be made because the target machine actively refused it?
- What does a lock statement do under the hood?
- Convert int to string?
- Could not load file or assembly or one of its dependencies
- Multiline string literal in C#
- What is the purpose of nameof?
- Where/how can I download (and install) the Microsoft.Jet.OLEDB.4.0 for Windows 8, 64 bit?
- Convert Enum to String
- Windows .NET API / Windows 7 / Bluetooth communication with Intel Curie Arduino / Genuino 101
- Error 1053 the service did not respond to the start or control request in a timely fashion
- Windows Application has stopped working :: Event Name CLR20r3
- Access to the path is denied
- Extension methods must be defined in a non-generic static class
- Metadata file ‘.dll’ could not be found
- C# List
to string with delimiter - Convert a list of strings to a single string
- How to resolve this System.IO.FileNotFoundException
- What’s the difference between struct and class in .NET?
- How do I declare a DefaultValue attribute whose value is an array of strings?
- Extension methods must be defined in a non-generic static class
- “An attempt was made to load a program with an incorrect format” even when the platforms are the same
- How to check if type of a variable is string?
- Invalid URI: The format of the URI could not be determined
- Multiple file-extensions searchPattern for System.IO.Directory.GetFiles
- C# – Illegal characters in path
- Getting The ASCII Value of a character in a C# string
- Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction
- Unable to read data from the transport connection : An existing connection was forcibly closed by the remote host
- Why did I get the compile error “Use of unassigned local variable”?
- Reading CSV file and storing values into an array
- Passing just a type as a parameter in C#
- The remote server returned an error: (407) Proxy Authentication Required
- How can I fix the error : “Unreachable Code Detected”
- Cannot access a disposed object – How to fix?
- How to split() a delimited string to a List
- Creating a comma separated list from IList
or IEnumerable - Remove element of a regular array
- How can I know if a process is running?
- How to solve “Could not establish trust relationship for the SSL/TLS secure channel with authority”
- windows could not start service on local computer error 5 access is denied
- Visual Studio keeps crashing
- Is there an equivalent to the Scanner class in C# for strings?
- Cannot attach the file *.mdf as database
- How can I implement static methods on an interface?
- Adding a newline into a string in C#
- How to format a string as a telephone number in C#
- Produce a random number in a range using C#
- How do I concatenate two arrays in C#?
- Which passwordchar shows a black dot (•) in a winforms textbox?
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- How to enable assembly bind failure logging (Fusion) in .NET
- How to make inline functions in C#
- .NET Framework 4.6 or a later update is already installed on this computer
- c# .net change label text
- Check if a string is a palindrome
- Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154
- How do I find the PublicKeyToken for a particular dll?
- When should I use a List vs a LinkedList
- What is a “first chance exception”?
- .NET Core vs Mono
- Convert JSON String to JSON Object c#
- Iif equivalent in C#
- Convert an array to string
- A certificate chain could not be built to a trusted root authority
- Declaration is incompatible with type
- How to enumerate an enum