Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the different between Console.Write("H") and Console.Write('H') in C#

Tags:

c#

console

What's the different between Console.Write("H") and Console.Write('H') in C#?

like image 901
Nano HE Avatar asked Dec 08 '22 05:12

Nano HE


2 Answers

One uses a string overload (the string "H"), one uses a char overload (the char 'H'). Both output the character H to the stream defined in Console.Out without adding a newline.

like image 94
user7116 Avatar answered May 14 '23 00:05

user7116


The difference is that in the first call, you're passing a string and in the second call, you're passing a char. Practically speaking, those two calls are equivalent.

like image 29
Adam Maras Avatar answered May 13 '23 23:05

Adam Maras