如何在两个类之间传递数组。 [英] How to Pass Array between Two classes.

查看:109
本文介绍了如何在两个类之间传递数组。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个classess。 A类和B类.A类包含字符串数组。我必须将该数组从A类传递给B.

解决方案

访问必须访问这里...



四种在层之间传递数据的方法

我建​​议你阅读:将数组作为参数传递(C#编程指南) [ ^ ]。

请试试!


hi
试试这段代码..



< pre lang =cs> public class ClassA
{
public void MethodB()
{
CLassB obj = new CLassB();
string [] array = { one 两个 };
obj.MethodA(array);
}
}
public class CLassB
{
public void MethodA( string [] arrayparameter)
{

}
}


There are two classess. Class A and Class B. Class A contains the Array of string. I have to pass that array from Class A to B.

解决方案

visit must visit here...

Four ways of passing data between layers


I would suggest you to read this: Passing Arrays as Parameters (C# Programming Guide)[^].
Please, try!


hi try this code..

public class ClassA
    {
        public void MethodB()
        {
            CLassB obj = new CLassB();
            string[] array  = {"one","two","three"};
            obj.MethodA(array);
        }
    }
    public class CLassB
    {
        public void MethodA(string[] arrayparameter)
        {

        }
    }


这篇关于如何在两个类之间传递数组。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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