What is the difference between a string and array. | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

What is the difference between a string and array.

c# c++

24th Sep 2017, 4:25 PM
Dries
Dries - avatar
5 ответов
+ 3
String Array holds {"multiple", "elements"}; String holds one "string value";
24th Sep 2017, 4:33 PM
D_Stark
D_Stark - avatar
+ 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.
24th Sep 2017, 7:02 PM
sneeze
sneeze - avatar
+ 1
String is an array of characters, with some extra features than regular array.
24th Sep 2017, 4:41 PM
Salekin
Salekin - avatar
0
examples of the two
24th Sep 2017, 6:09 PM
Dries
Dries - avatar
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
2nd Jan 2019, 5:46 AM
rahul kumar
rahul kumar - avatar