重命名一个函数在C# [英] rename a function in C#

查看:137
本文介绍了重命名一个函数在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法在C#中重命名System.Console.WriteLine
,以便在我的C#/ console / visual studio程序中,我可以写

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?

推荐答案

你的目标看起来很奇怪,没有办法做到这一点C#。或者,您可以在类中添加一个方法并使用它。

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.

这篇关于重命名一个函数在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆