Similar Posts

Subscribe
Notify of
8 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
zalto
2 months ago

Why buy a bottle of beer and not a whole box if you want to drink beer?
Costs more, you have more towing, you need more parking space.
More is not always better.

NorbertWillhelm
2 months ago

char is a single unicode character, unless it is a field of char or a list of char.

Xandros0506
2 months ago

Char has existed since C. And a string is ultimately nothing other than a Char array, which was then introduced with C++ for the first time as a string in this language.

The fact that C# still uses Char is ultimately due to the fact that for C# a string is nothing but a Char sequence. And if you treat a string as a Char sequence, the language should already know what a Char is.

Kelec
2 months ago

No, you can’t.

A method like char.IsControl or similar makes no sense on string only with index.

So that algorithms can be imaged in a clean manner, a single character can be tested in a string, there is just Char which represents a character in the string.

And these methods can now be used if you pass the string sign for characters.

Suiram1
2 months ago

A char is a single-line character while a string is a whole string and that is something different. In addition, a char a struct is therefore a value type which can be clearly converted into an int and back.

lg Suiram1

scatha
2 months ago

Data type “string” is a string with any previously unknown length

Data type “char” is always exactly a single character.

An array of char is a sequence of characters with fixed length.

Compilers can thus drive different optimizations and the code is executed more quickly.

PhilosoGeek218
2 months ago

Isn’t char important to access single characters on seperate? At least in other languages, I can be mistaken!