希望C#可以提供方法别名 mutipart function names hope #7045
Replies: 4 comments 2 replies
-
I don't speak Mandarin, so I may have misunderstood you, but according to Google you are asking for aliases for method names, as per your code example. Creating four methods, This feels like a “YAGNI” idea. It creates complexity through aiming to offer flexibility. Keep it simple is the key here. Sorry if this seems negative, but I really can’t see how this change would bring any benefits to C# developers. |
Beta Was this translation helpful? Give feedback.
-
Further, if you really wanted to do this, the code to do it is currently trivial and doesn't require much extra typing than your proposal: public static string GetText(string path) => ReadString(path);
public static string GetString(string path) => ReadString(path);
public static string ReadText(string path) => ReadString(path);
public static string ReadString(string path)
{
// code to get the string from the path
} |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Aliasing methods is trivial, since you can easily achieve this by defining an inlinable function calling them. |
Beta Was this translation helpful? Give feedback.
-
希望C#可以提供方法别名 mutipart function names hope
比如文本读取方法,我们可以这样定义 as a function of mutipart names
public static string GetText,GetString,ReadText,ReadString(string path);
Beta Was this translation helpful? Give feedback.
All reactions