+ 2

is string a data type??

4th Nov 2016, 7:11 AM
Gaurav Aggarwal
3 Answers
+ 3
yes, a string is a data type, but it's not considered a primitive one ( like int for example)
4th Nov 2016, 7:38 AM
Cosmin Serboteiu
Cosmin Serboteiu - avatar
+ 2
Yes, String is a data type but in most of the programming language, it's not considered a primitive language because, there's no way you can determine the memory allocation that is required for a string. A string can be of length 10 or length 5, a string can contain one word or 1000. To solve this issue, most of the language consider string to be an array of characters. Conventionally a single char takes 1 byte, so making string an array of byte, you can allocate bytes according to how many character that string has. for example, if you have, "This is an example." It has a length of 19, including the spaces in between the words. Conventionally, if you had spaces before the first word or the last word but the spaces were inside the quote sign, it will be included in the array that will be created from this string. the array will look like: [T][h][i][s][ ][i][s][ ][a][n][ ][e][x][a][m][p][l][e][.]
4th Nov 2016, 7:47 AM
Tauki Tahmid
Tauki Tahmid - avatar
+ 1
see that C# provides String (class) and string (primitive). the language is case sensitive.
4th Nov 2016, 10:14 AM
Julio Cezar
Julio Cezar - avatar