בנימן הגלילי בנימן הגלילי - 3 months ago 20
C# Question

rename a function in C#

is there a way in C# to rename System.Console.WriteLine
so that in my C#/console/visual studio program I could write

printf("hello");
//instead of
System.Console.WriteLine("Hello"); //??


What would this be, a class? a namespace? Do I do this in the header or inside of main?

Answer

Your target looks strange and there is no way to do this in c#. Alternatively you can add a method in a class and use it.

private static void printf(string value)
{
    System.Console.WriteLine(value);
}

Note: above method works only in the class which you write the above method.