Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It is possible to write only WriteLine instead of Console.WriteLine in C#?

I'm a completely noob and a begginer programmer in C# but I was reading about Roslyn and 'What's new in C# 7.0' and I found something very interesting that I can't find out the answer I need.

In this link, all the examples given contain something like WriteLine("something"); instead of Console.WriteLine("something");, for example:

public void PrintCoordinates(Point p)
{
  p.GetCoordinates(out int x, out int y);
  WriteLine($"({x}, {y})");
}

My question is: How can I do that?

Would something like this work?

public static void WriteLine(string v) => Console.WriteLine(v);
like image 424
Andrei Paciurca Avatar asked Jun 01 '17 10:06

Andrei Paciurca


Video Answer


1 Answers

Try using static directive:

 using static System.Console;

 ...

 WriteLine("some text");
like image 190
Dmitry Bychenko Avatar answered Feb 22 '23 08:02

Dmitry Bychenko