Timeline for answer to What is the difference between String and string in C#? by artur02
Current License: CC BY-SA 3.0
Post Revisions
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 27, 2024 at 16:40 | comment | added | Craig Tullis | @ABaumstumpf Meh. I despise the proper-cased system class library names for regular use in workaday code. They do not increase readability. Int16 and short are the same thing. Int32 and int are the same thing. Int64 and long are the same thing in C#. String and string are literally the same thing. The compiler simply substitutes string with System.String. Always. If they're part of a class library interface, that's different. | |
| Jun 26, 2024 at 9:13 | comment | added | ABaumstumpf | @CraigTullis - that is my point - it is defined but NOT descriptive. | |
| Jun 25, 2024 at 13:26 | comment | added | Craig Tullis | @ABaumstumpf short is a 16 bit int in C#. Always, on every platform. learn.microsoft.com/en-us/dotnet/csharp/language-reference/… | |
| Jun 21, 2024 at 7:41 | comment | added | ABaumstumpf |
@CraigTullis being well-defined and being descriptive are two VERY different concepts. The x86 instruction GF2P8AFFINEINVQB is well-defined but certainly in no way descriptive. That is the same with short: "What does it tell us? Oh, something is "short"... is it a short poem? A short task? A short string? Shortcircuit-logic? Ahhh - it is an integral type that is shorter than the normal integer-type.... how big is int and what makes short shorter?" Of course - you have to learn that cause it is not really descriptive. It is a remnant of old C where "short" actually just is "short int"
|
|
| Dec 28, 2022 at 18:37 | comment | added | Narish |
This is all tomato tomato. If I was doing something where I had to be counting bytes I would probably rely on IntXX, while in every other instance I would just use short int long, etc. I'm thankful that I can do either and I will leverage that flexibility to best serve my need. I also don't understand this argument because C/C++ does not use the intXX aliases at all, as far as I know C# did that on its own. Great low level discussion tho!
|
|
| Oct 14, 2020 at 15:49 | comment | added | Craig Tullis | But short, not, long, float, double, et al are descriptive, because they’re in the language spec. C# is not C. I prefer them on declarations because they’re concise, small, and aesthetically pleasing. I do prefer the Torre library names on API’s where the API has a data type dependency. | |
| Dec 9, 2018 at 2:29 | comment | added | Nyerguds |
@Craig I dig into lots of old proprietary game formats where I do have to think about that all the time, though. And then using Int16, Int32 and Int64 is a lot more transparent in the code than using the rather nondescriptive short, int and long
|
|
| Dec 8, 2018 at 2:47 | comment | added | Craig Tullis |
@Nyerguds There are two reasons to simply not worry about it. One is that int is defined in the C# language spec as a 32 bit integer regardless of the hardware. C#, despite a shared heritage in the mists of time, is not actually C. Changing int to a 64 bit integer would be a breaking change in the specification and the language. It would also require redefining long, as long is currently the 64 bit integer. The other reason not to worry is irrelevant since the types will never change, but .NET is just abstract enough that 99% of the time you don't have to think about it anyway. ;-)
|
|
| Jan 21, 2017 at 17:39 | comment | added | Peter - Reinstate Monica | @MyDaftQuestions I concur. If anything it would make sense to consistently use the .net types because they are language ignorant and the type is obvious, independent of any language (do I know all of F#'s or VB's idiosyncrasies?). | |
| Apr 28, 2016 at 11:41 | comment | added | Nyerguds | I personally prefer using "Int32", since it immediately shows the range of the value. Imagine if they upgraded the type of "int" on later higher-bit systems. 'int' in c is apparently seen as "the integer type that the target processor is most efficient working with", and defined as "at least 16 bit". I'd prefer predictable consistency there, thank you very much. | |
| Oct 4, 2012 at 10:37 | history | made wiki | Post Made Community Wiki by Inverted Llama | ||
| Feb 12, 2012 at 16:15 | history | post merged (destination) | |||
| Dec 3, 2011 at 19:53 | history | edited | Ry-♦ | CC BY-SA 3.0 |
It's "well-known."
|
| Nov 19, 2011 at 9:39 | history | edited | Christian Specht | CC BY-SA 3.0 |
code tags
|
| Oct 19, 2008 at 0:50 | vote | accept | mmutilva | ||
| Apr 28, 2011 at 1:46 | |||||
| Oct 18, 2008 at 17:25 | history | answered | artur02 | CC BY-SA 2.5 |