Timeline for What is the difference between String and string in C#?
Current License: CC BY-SA 4.0
Post Revisions
146 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| yesterday | comment | added | Tony Chu | "The Worm is the Spice. The Spice is the Worm." -- Paul Atreides | |
| Jun 4 at 15:18 | comment | added | Riky Macias | string (lowercase) This is a C# keyword. It’s an alias for System.String. Preferred in most code because it feels more natural and consistent with other built-in types (int, bool, double, etc.). String (capital S) This is the actual class name defined in the .NET Framework (System.String). You can use it directly, and it’s functionally identical to string. | |
| Nov 11, 2025 at 21:19 | comment | added | Katherin Fabiola Gonzales Coel | No entiendo, help me please | |
| Nov 15, 2024 at 13:18 | history | edited | tylkonachwile | CC BY-SA 4.0 |
deleted 39 characters in body
|
| Nov 15, 2024 at 13:12 | history | edited | tylkonachwile | CC BY-SA 4.0 |
added 39 characters in body
|
| Apr 16, 2024 at 0:18 | comment | added | George Birbilis | indeed, probably wasn't thinking straight when I mentioned boxing/unboxing, removed comment to avoid confusion | |
| Apr 15, 2024 at 13:48 | comment | added | Olivier Jacot-Descombes |
@GeorgeBirbilis - Boxing/unboxing has nothing to do with this, because of two reasons: 1. System.String/string is a reference type. 2. Unlike in Java where Integer is the boxed type and int is the unboxed type, this distinction is not made name-wise in C#, since generics work with unboxed value types.
|
|
| Feb 4, 2024 at 4:56 | answer | added | Nima Habibollahi | timeline score: -3 | |
| Apr 28, 2023 at 21:39 | history | edited | Evorlor | CC BY-SA 4.0 |
added 1 character in body
|
| Mar 31, 2023 at 9:07 | comment | added | Darshan Adakane | No difference. 'string' (lower case) is just an alias for System.String. | |
| Mar 11, 2023 at 6:30 | comment | added | Chiara Tumminelli | In C#, string is an alias for System.String, which means they are the same type. The only difference is in the naming convention: string is written in lowercase, whereas String is capitalized. There is no difference in functionality or performance between string and String, so which one you use is entirely up to personal preference. However, the convention is to use string in C# code because it is more commonly used and looks cleaner. | |
| Mar 9, 2023 at 0:00 | history | unpinned in a collective | CommunityBot | ||
| Feb 8, 2023 at 15:48 | history | pinned in a collective | Nikki Stephens | ||
| Jan 12, 2023 at 9:04 | comment | added | SimonC | Oh no, I totally agree with you! That's just how I interpreted his comment and thought mentioning the (old) style was possibly of some value to someone here. | |
| Jan 11, 2023 at 18:47 | comment | added | Craig Tullis | @SimonC I wouldn't use String for static methods either. I dislike it, and there's no point in it. However; The System.String class is still the implementation of the native string data type, and "string" is an alias for it. I do like that the IDE flags it, but the downside to that is all of the massive roaming hordes of developers who routinely completely ignore that sort of thing, which ultimately just makes the code look even worse in the IDE with all of the grayed out junk and squiggly underlines all over the place. I have the same gripe with developers who ignore compiler warnings. | |
| Jan 11, 2023 at 12:42 | comment | added | SimonC |
@CraigTullis I think what he meant, is that Visual Studio will grey-out usage of String, and will suggest replacing it with string. Although I do remember some MSDN page saying that string should be used for params and variables, and String when using static methods
|
|
| Jan 1, 2023 at 20:36 | answer | added | Abrar ul Hassan | timeline score: -3 | |
| Oct 31, 2022 at 16:01 | answer | added | DanConsultant | timeline score: -9 | |
| Sep 12, 2022 at 10:35 | history | edited | Ramesh R | CC BY-SA 4.0 |
improved formatting
|
| Jul 20, 2022 at 0:00 | history | unpinned in a collective | CommunityBot | ||
| Jun 21, 2022 at 15:33 | history | pinned in a collective | John Wright | ||
| Jun 15, 2022 at 15:20 | comment | added | SacredGeometry | @JesseWilliams I didn't use a "using directive" I just used an explicit namespace. So yes, I did. | |
| Jun 13, 2022 at 17:23 | comment | added | Jesse Williams | @SacredGeometry - no, you referenced System inline... so you did not. | |
| Jun 2, 2022 at 14:22 | answer | added | Nima Habibollahi | timeline score: -5 | |
| May 27, 2022 at 13:28 | history | edited | spaleet | CC BY-SA 4.0 |
simplified
|
| Feb 4, 2022 at 7:39 | comment | added | luka | Essentially, there is no difference between string and String. String is a class in the .NET framework in the System namespace. The fully qualified name is System.String. Whereas, the lower case string is an alias of System.String. In my opinion I advise you to use string over String. However, depend on you . You can use any of them. I use System.String class to use any built-in string methods e.g., String.IsNullOrEmpty(). | |
| Jan 19, 2022 at 15:42 | history | unpinned in a collective | Carrott♦ | ||
| Jan 19, 2022 at 15:41 | history | pinned in a collective | Carrott♦ | ||
| Dec 31, 2021 at 19:26 | review | Suggested edits | |||
| Jan 2, 2022 at 8:56 | |||||
| Dec 18, 2021 at 17:20 | answer | added | Ran Turner | timeline score: 5 | |
| Oct 4, 2021 at 14:34 | history | unpinned in a collective | Aruna Telang | ||
| Oct 4, 2021 at 14:33 | history | pinned in a collective | Aruna Telang | ||
| Sep 30, 2021 at 18:22 | history | unpinned in a collective | Aruna Telang | ||
| Sep 28, 2021 at 15:43 | history | pinned in a collective | Aruna Telang | ||
| Sep 28, 2021 at 13:14 | history | unpinned in a collective | Aruna Telang | ||
| Sep 28, 2021 at 13:14 | history | pinned in a collective | Aruna Telang | ||
| Sep 27, 2021 at 18:16 | history | unpinned in a collective | Aruna Telang | ||
| Sep 27, 2021 at 18:16 | history | pinned in a collective | Aruna Telang | ||
| Mar 1, 2021 at 20:12 | answer | added | TRK | timeline score: 5 | |
| Dec 31, 2020 at 1:37 | comment | added | SacredGeometry | System.String myString = "Ha!"; @Wilsu No? I just did. | |
| Apr 10, 2020 at 21:34 | history | edited | S.S. Anne | CC BY-SA 4.0 |
deleted 12 characters in body
|
| Aug 16, 2019 at 14:11 | answer | added | MicroservicesOnDDD | timeline score: 5 | |
| Jul 2, 2019 at 5:44 | answer | added | Ali Sufyan | timeline score: 2 | |
| Jun 25, 2019 at 12:06 | answer | added | Ted Mucuzany | timeline score: 5 | |
| May 22, 2019 at 16:50 | review | Close votes | |||
| May 27, 2019 at 0:00 | |||||
| May 14, 2019 at 15:15 | answer | added | Gonçalo Garrido | timeline score: 4 | |
| Apr 11, 2019 at 8:39 | answer | added | aloisdg | timeline score: 82 | |
| Dec 8, 2018 at 2:14 | comment | added | Craig Tullis |
@Sangeeta What are you saying? The System.String class is still there, and the string keyword is still an alias for it. Just like System.Int32 and int. They are literally the same thing.
|
|
| Dec 1, 2018 at 17:44 | answer | added | Braham Prakash Yadav | timeline score: 6 | |
| Nov 29, 2018 at 9:53 | comment | added | Sangeeta | Since 2014 conventions have changed a lot in .net framework. Now there's no existence for String (capital s) while declaring variables. only alias string (small s) is available. Microsoft might wanted to remove confusing programming approach! | |
| Oct 16, 2018 at 17:32 | answer | added | user9131762 | timeline score: 5 | |
| Jul 22, 2018 at 16:30 | answer | added | user8207463 | timeline score: 7 | |
| Jul 12, 2018 at 1:35 | answer | added | Jaider | timeline score: 7 | |
| Jun 27, 2018 at 16:42 | history | rollback | habib |
Rollback to Revision 20
|
|
| Jun 27, 2018 at 16:40 | history | rollback | habib |
Rollback to Revision 19
|
|
| Jun 27, 2018 at 16:23 | history | edited | habib |
Add alias tag
|
|
| Feb 8, 2018 at 8:28 | answer | added | wild coder | timeline score: 14 | |
| Feb 1, 2018 at 13:13 | answer | added | v.slobodzian | timeline score: 10 | |
| Jan 31, 2018 at 13:43 | history | edited | Ramesh Rajendran | CC BY-SA 3.0 |
edited body
|
| Jan 18, 2018 at 13:40 | answer | added | BanksySan | timeline score: 25 | |
| Jan 12, 2018 at 9:19 | answer | added | Hasan Jafarov | timeline score: 8 | |
| Jan 8, 2018 at 20:24 | review | Suggested edits | |||
| Jan 9, 2018 at 0:59 | |||||
| Jan 5, 2018 at 19:52 | answer | added | Taslim Oseni | timeline score: 15 | |
| Dec 18, 2017 at 17:16 | history | edited | Milad Rashidi | CC BY-SA 3.0 |
Improved formatting
|
| Nov 16, 2017 at 12:18 | review | Suggested edits | |||
| Nov 16, 2017 at 12:26 | |||||
| Nov 10, 2017 at 11:34 | answer | added | Jineesh Uvantavida | timeline score: 8 | |
| Oct 18, 2017 at 15:11 | answer | added | DavidWainwright | timeline score: 8 | |
| Oct 2, 2017 at 16:27 | review | Close votes | |||
| Oct 6, 2017 at 0:05 | |||||
| Sep 16, 2017 at 19:27 | history | edited | Boris Modylevsky |
tag was added
|
|
| Jul 25, 2017 at 23:35 | history | edited | Brandon Minnick | CC BY-SA 3.0 |
Added C# formatting
|
| May 28, 2017 at 18:15 | review | Close votes | |||
| Jun 1, 2017 at 0:01 | |||||
| May 22, 2017 at 9:58 | review | Close votes | |||
| May 26, 2017 at 0:04 | |||||
| Mar 25, 2017 at 5:04 | answer | added | Saurabh | timeline score: 12 | |
| Dec 20, 2016 at 0:24 | comment | added | Roland Kwee |
For someone coming from Algol and Fortran, this discussion shows there is something wrong with string. It is needed to abbreviate System.String, but, as an alias, it seems quite like, but not exactly the same thing. After several years of C#, though, I'd say, it is safe to simply use string and string.Format() and not to worry about System.String.
|
|
| Dec 11, 2016 at 0:38 | answer | added | sayah imad | timeline score: 7 | |
| Jul 22, 2016 at 15:18 | history | edited | Steve Chambers | CC BY-SA 3.0 |
Changed title for consistency with other top questions and removed duplication in question text
|
| S Jul 9, 2016 at 20:02 | history | suggested | manizheh |
I add "type" tag to this post.
|
|
| Jul 9, 2016 at 18:13 | review | Suggested edits | |||
| S Jul 9, 2016 at 20:02 | |||||
| Jun 4, 2016 at 11:20 | answer | added | hubot | timeline score: 13 | |
| Apr 5, 2016 at 10:50 | history | edited | Sindhoo Oad | CC BY-SA 3.0 |
formatting
|
| Jan 20, 2016 at 10:53 | answer | added | Pritam Jyoti Ray | timeline score: 9 | |
| Dec 28, 2015 at 9:03 | answer | added | yazan_ati | timeline score: 8 | |
| Nov 30, 2015 at 8:52 | comment | added | Wilsu |
You can use string without a using directive for System. You can't do that with String.
|
|
| Oct 1, 2015 at 17:43 | answer | added | tic | timeline score: 17 | |
| Sep 19, 2015 at 16:00 | history | edited | rav_kr | CC BY-SA 3.0 |
readability
|
| Jun 19, 2015 at 12:11 | history | rollback | jazzpi |
Rollback to Revision 9
|
|
| Apr 7, 2015 at 10:30 | answer | added | Anuja Lamahewa | timeline score: 26 | |
| Apr 1, 2015 at 10:40 | review | Suggested edits | |||
| Apr 1, 2015 at 11:12 | |||||
| Feb 5, 2015 at 12:08 | history | edited | Chandrika | CC BY-SA 3.0 |
deleted 4 characters in body
|
| Jan 29, 2015 at 9:28 | history | edited | codermaster | CC BY-SA 3.0 |
added 30 characters in body
|
| Jan 15, 2015 at 14:21 | answer | added | Jeppe Stig Nielsen | timeline score: 134 | |
| Dec 30, 2014 at 13:43 | answer | added | Teter28 | timeline score: 15 | |
| Dec 2, 2014 at 8:22 | comment | added | O. R. Mapper |
@KirkWoll: According to the language specification, the language itself must consider string to be exactly the same as the BCL type System.String, nothing else. That is not ambiguous at all. Of course, you can implement your own compiler, using the C# grammar, and use all of the tokens found like that for something arbitrary, unrelated to what is defined in the C# language specification. However, the resulting language would only be a C# lookalike, it could not be considered C#.
|
|
| Dec 2, 2014 at 3:05 | comment | added | Kirk Woll |
@O.R.Mapper, but the fact remains that string is a lexical construct of the C# grammar whereas System.String is just a type. Regardless of any explicit difference mentioned in any spec, there is still this implicit difference that could be accomodated with some ambiguity. The language itself must support string in a way that the implementation is not (quite) so obligated to consider for a particular class in the BCL.
|
|
| Oct 29, 2014 at 16:42 | history | edited | alexyorke | CC BY-SA 3.0 |
clarified slightly
|
| Jul 26, 2014 at 15:40 | answer | added | InfZero | timeline score: 8 | |
| Jun 20, 2014 at 3:55 | answer | added | Kalu Singh Rao | timeline score: 7 | |
| Jun 11, 2014 at 11:15 | answer | added | Vijay Singh Rana | timeline score: 6 | |
| Jun 11, 2014 at 5:26 | answer | added | Neel | timeline score: 47 | |
| May 20, 2014 at 14:34 | answer | added | Geeky Ninja | timeline score: 9 | |
| Mar 7, 2014 at 13:09 | answer | added | zap92 | timeline score: 23 | |
| Jan 15, 2014 at 18:03 | answer | added | Shivprasad Koirala | timeline score: 228 | |
| Nov 1, 2013 at 15:21 | answer | added | user2771704 | timeline score: 53 | |
| Jul 18, 2013 at 17:52 | history | edited | Wooble |
edited tags
|
|
| Jul 11, 2013 at 10:37 | history | edited | user2140173 | CC BY-SA 3.0 |
added 26 characters in body
|
| Apr 16, 2013 at 14:41 | history | edited | Gennady Vanin Геннадий Ванин |
edited tags
|
|
| Dec 6, 2012 at 7:13 | history | edited | Peter O. | CC BY-SA 3.0 |
deleted 4 characters in body; edited title
|
| Oct 8, 2012 at 8:22 | answer | added | Coder | timeline score: 45 | |
| S Oct 4, 2012 at 10:37 | answer | added | Inverted Llama | timeline score: 16 | |
| S Oct 4, 2012 at 10:37 | history | made wiki | Post Made Community Wiki by Inverted Llama | ||
| Oct 3, 2012 at 10:52 | answer | added | Zaid Masud | timeline score: 30 | |
| Aug 24, 2012 at 15:22 | answer | added | Michael Ray Lovett | timeline score: 77 | |
| Apr 22, 2012 at 14:57 | history | protected | CommunityBot | ||
| S Apr 21, 2012 at 19:11 | history | suggested | Liam McInroy | CC BY-SA 3.0 |
Changed String to `String` so in code, and took out C# in title because it is in tags, also example
|
| Apr 21, 2012 at 18:33 | review | Suggested edits | |||
| S Apr 21, 2012 at 19:11 | |||||
| S Feb 12, 2012 at 16:15 | history | post merged (destination) | |||
| Jan 14, 2012 at 23:49 | history | post merged (destination) | |||
| Jan 14, 2012 at 22:51 | answer | added | Joe Alfano | timeline score: 83 | |
| Jan 14, 2012 at 22:47 | answer | added | Oded | timeline score: 60 | |
| Oct 21, 2011 at 1:10 | answer | added | JeeShen Lee | timeline score: 96 | |
| Aug 24, 2011 at 9:25 | answer | added | Dot NET | timeline score: 38 | |
| May 31, 2011 at 11:20 | answer | added | RolandK | timeline score: 102 | |
| Apr 28, 2011 at 1:46 | vote | accept | mmutilva | ||
| S Feb 12, 2012 at 16:15 | |||||
| Apr 25, 2011 at 6:06 | answer | added | user576533 | timeline score: 78 | |
| Jan 28, 2011 at 10:08 | answer | added | claudioalpereira | timeline score: 93 | |
| Mar 17, 2010 at 16:06 | history | edited | SoftwareGeek |
edited tags
|
|
| Mar 17, 2009 at 20:29 | answer | added | Rasmus Faber | timeline score: 224 | |
| Feb 24, 2009 at 5:14 | answer | added | Simon_Weaver | timeline score: 529 | |
| Oct 19, 2008 at 1:15 | answer | added | Lloyd Cotten | timeline score: 140 | |
| Oct 19, 2008 at 1:04 | answer | added | TraumaPony | timeline score: 362 | |
| Oct 19, 2008 at 0:50 | vote | accept | mmutilva | ||
| Apr 28, 2011 at 1:46 | |||||
| Oct 18, 2008 at 18:52 | answer | added | Jon Skeet | timeline score: 3836 | |
| Oct 18, 2008 at 18:26 | answer | added | Pradeep Kumar Mishra | timeline score: 166 | |
| Oct 18, 2008 at 17:25 | answer | added | artur02 | timeline score: 841 | |
| Oct 18, 2008 at 16:50 | answer | added | Hallgrim | timeline score: 180 | |
| Oct 18, 2008 at 16:50 | answer | added | TheSoftwareJedi | timeline score: 229 | |
| Sep 22, 2008 at 19:40 | answer | added | Ishmael | timeline score: 113 | |
| Sep 3, 2008 at 18:58 | answer | added | Anthony Mastrean | timeline score: 253 | |
| Aug 27, 2008 at 18:21 | answer | added | user3296 | timeline score: 480 | |
| Aug 18, 2008 at 17:58 | answer | added | Mel | timeline score: 80 | |
| Aug 15, 2008 at 23:00 | answer | added | Luke Foust | timeline score: 600 | |
| Aug 10, 2008 at 8:47 | vote | accept | Lance Fisher | ||
| Aug 10, 2008 at 7:27 | answer | added | urini | timeline score: 201 | |
| Aug 10, 2008 at 7:26 | answer | added | Ronnie | timeline score: 318 | |
| Aug 10, 2008 at 7:22 | answer | added | Derek Park | timeline score: 7128 | |
| Aug 10, 2008 at 7:18 | history | asked | Lance Fisher | CC BY-SA 2.5 |