+ 1
What's the difference between a String and a Char Array?
4 ответов
+ 1
From the c# course
//start quote
arrays & strings
working with strings Strings
It’s common to think of strings as arrays of characters. In reality, strings in C# are objects. When you declare a string variable, you basically instantiate an object of type String.
//end quote
If strings were arrays of chars they would not have all these nice methods like "Length", "Contains" , "EndsWith"
Yes the string object has a indexer but that does not make it a array.
+ 5
as far as i know a string is an array of chars
+ 2
I like to think of them more as a vector, but yes, they are an object.
0
in char array we can assign a single character per position. in string array we can assign many chars(string) per position. simple enough! 🙆