How to shortcut Console.WriteLine(); in C# ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to shortcut Console.WriteLine(); in C# ?

The shortcut that can read any type of data. Var, string, integer, etc.

21st Oct 2022, 6:16 PM
1ntry
1ntry - avatar
2 Answers
+ 2
it can write any types that defines the ToString() method. this includes integer, strings, double, and many more. these should work: Console.WriteLine(1); Console.WriteLine("Hello"); Console.WriteLine(1.5); if you want a shortcut, you could define a print static method public static void Print(object obj) { Console.WriteLine(obj); } it's now a bit shorter to write. I hope this helps :) if I misunderstood your question, let me know!
21st Oct 2022, 6:35 PM
Apollo-Roboto
Apollo-Roboto - avatar
0
Apollo-Roboto Nicee. But I need a shortcut that support blank line too :)
23rd Oct 2022, 7:40 PM
1ntry
1ntry - avatar