c# – 如何让方法在同一个类中调用另一个方法?
发布时间:2020-12-16 00:22:51 所属栏目:百科 来源:网络整理
导读:参见英文答案 How to make method call another one in classes C#?????????????????????????????????????1个 我有一个名为methods.cs的类包含两个方法. 例如method1和method2 我想让method2调用method1 代码澄清: public static void Method1(){// Method1
参见英文答案 >
How to make method call another one in classes C#?????????????????????????????????????1个
我有一个名为methods.cs的类包含两个方法. 例如method1和method2 我想让method2调用method1 代码澄清: public static void Method1() { // Method1 } public static void Method2() { // Method2 } 我想让Method2调用Method1.我怎样才能做到这一点? 解决方法
很高兴看到你寻求帮助!为了在另一个方法中调用Method,同一个Class中包含的方法非常简单.只需通过它的名字来称呼它!
Here is a nice little tutorial on Methods和我的例子在下面!
public class ClassName { // Method definition to call in another Method public void MethodToCall() { // Add what you want to be performed here } // Method definition performing a Call to another Method public void MethodCalling() { // Method being called. Do this by using its Method Name // be sure to not forget the semicolon! :) MethodToCall(); } } 祝你好运,希望对你有所帮助! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |