+ 1

What's the difference between a String and a Char Array?

25th Jun 2017, 6:35 PM
Damitha D. Wijayasiri
Damitha D. Wijayasiri - avatar
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.
25th Jun 2017, 7:21 PM
sneeze
sneeze - avatar
+ 5
as far as i know a string is an array of chars
25th Jun 2017, 6:39 PM
Welliton Malta
Welliton Malta - avatar
+ 2
I like to think of them more as a vector, but yes, they are an object.
25th Jun 2017, 9:15 PM
jay
jay - avatar
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! 🙆
21st Jul 2017, 1:02 AM
P B D Madushanka
P B D Madushanka - avatar