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?

14th Apr 2020, 12:50 PM
Shawn
Shawn - avatar
1 Réponse
+ 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"..
14th Apr 2020, 1:01 PM
Jayakrishna 🇮🇳