+ 1
What is the difference between a string and array.
c# c++
5 Antworten
+ 3
String Array holds {"multiple", "elements"};
String holds one "string value";
+ 3
Arrays are not strings
The fact that string variable can have indexers does not make a string a array.
I loved the explanation in the c# tutorial
Array & strings -> working with strings
string mystring = "hello world";
This is a string
string[] arr1 = new string[] { "one", "two", "three" };
This is a array of strings
string[] arr2 = { "one", "two", "three" };
This is also an array of strings
int[] array = { 5, 6, 7 };
This is an array of integers
https://www.dotnetperls.com/array
char[] array1 = { 'h', 'e', 'l','l','o' };
This is an array of characters.
strings and arrays can hold the same data but that does not make them the same type.
https://www.dotnetperls.com/char-array
Array's can hold many datatypes, depeding on their definition
string only hold characters.
+ 1
String is an array of characters, with some extra features than regular array.
0
examples of the two
0
An array is a collection of like variables that share a single name. The individual elements of an array are referenced by appending a subscript, in square brackets, behind the name.
Strings are similar to arrays with just a few differences. Usually, the array size is fixed, while strings can have a variable number of elements. Arrays can contain any data type (char short int even other arrays) while strings are usually ASCII characters terminated with a NULL (0) character. In general we allow random access to individual array elements. On the other hand, we usually process strings sequentially character by character from start to end.
http://csharp.net-informations.com/collection/csharp-array.htm