亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在另一個文件上使用一個文件中的方法

如何在另一個文件上使用一個文件中的方法

C#
HUX布斯 2023-09-24 11:13:10
我想在另一個文件(類)中使用一個方法。你可以看到// first class filenamespace AutomatskI{    class Method{         public void client()         {           // some code         }// second class filenamespace AutomatskaIA{    class AutomaticTestRun        public void login()           {             // Here i want to use that code              client();           }
查看完整描述

1 回答

?
慕勒3428872

TA貢獻1848條經驗 獲得超6個贊

您應該在第二個庫中引用您的第一個庫


// Reference your first library like this

using AutomatskI;


namespace AutomatskaIA

{

    class AutomaticTestRun

    {

        public void login()

        {

            // Then reach this class method like this

            Method method = new Method();

            method.client();

            // Or use a static class instead by putting a 'static' tag in class name. 

            // So you don't have to create an instance of this class in order

            // to use its methods. Then you can do it like this:

            // Method.client();

        }

 // ...

請在發布之前格式化您的代碼,以便人們更輕松地閱讀您的代碼。


查看完整回答
反對 回復 2023-09-24
  • 1 回答
  • 0 關注
  • 111 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號