从其他类文件调用方法 [英] call a method from a different class file

查看:83
本文介绍了从其他类文件调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.我有一个名为AqM.cs的类文件,并且我正在PirM.cs中工作.我想在PirM.cs中调用方法"Rmv"从AqM.cs文件中获取(方法为public).谢谢!

解决方案

您需要将引用传递给实现该方法的对象,除非它是静态的.  

 

如果该方法是静态的,则可以执行以下操作:

AqM.Rmv();  // If AqM is the class name


hi. i have a class file called AqM.cs and i am working in PirM.cs. i want to call in PirM.cs the method "Rmv" from AqM.cs file ( the method is public ). thank you!

解决方案

You'll need to pass a reference to an object that implements the method, unless it's static.  

 

If the method is static, you can just do:

AqM.Rmv();  // If AqM is the class name


这篇关于从其他类文件调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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