0
c#: strings - " vs '
hi, i was having some trouble differentiating the use of a double inverted comma " or a single inverted comma ' in strings and characters. can anyone help me out?
1 Antwort
+ 1
"String" is a string. Anything in between, double coute is a string..
Except, in some languages, in output statement, there we can use escape sequence charecter to replace that with a constant values like %d, %s \n.. {0},{1},...
Ex: str="string with \n 2 lines";
Console.WriteLine("string {0}", str);
In single coute, we write only single charecter..
Ex: 'a', '1', '@'.
Again here exception for escape sequence charecter like '\n' is single charecter.
Invalids: 'abcd', '102'...
Correct one : "abcd", "102"..