隐含转换问题 [英] Implicit convertion issue

查看:65
本文介绍了隐含转换问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii,



我有三个类似Vendordata,Vendorcompany,VendorBank





Hii ,

I have three classe like "Vendordata","Vendorcompany","VendorBank"


public class Vendordata
  {

      public string name;
      public string country;
      public Vendorcompany[] vend;
      public VendorBank[] bank;


  }







public class Vendorcompany
   {

       public string vendorcompany;
       public string companyname;
       public string place;
   }







public class VendorBank
   {

       public string BankName;
       public string BankPlace;
       public string BankAccountNumber;

   }









我需要将Vendordata作为输入参数发送给函数。





我创建了Vendordata类的对象





Vendordata vnddata =新的Vendordata();





再次我需要为Vendordata类中的vendorcompany类分配值。所以当我尝试为该类创建对象时





vnddata.bank = new VendorBank();





i得到的错误如不能隐含转换VendorBank to VendorBank []



请帮我解决





I need to send the "Vendordata" as input parameter to a function.


I have created an object of the class "Vendordata"


Vendordata vnddata = new Vendordata();


and again i need to assign the values for the class "vendorcompany" present in the Vendordata class.so when i try to create object for that class


vnddata.bank = new VendorBank();


i got the error like "Cannot implicity convert VendorBank to VendorBank[]"

Please help me out

推荐答案

这是因为你已将Bank声明为阵列。你有:



It's because you have declared Bank as an array. You have:

public VendorBank[] bank;





如果您不希望它是一个数组,请将其定义为:





If you don't want it to be an array define it as:

public VendorBank bank;


这篇关于隐含转换问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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