如何为数组变量赋值时,它在不同的类中声明?以下是用于更容易理解我的问题的示例代码: -如何为具有数组变量的类声明和赋值?
// Below is a class customer that has three parameters:
// One string parameter and Two int array parameter
public class Customer
{
public string invoiceFormat { get; set; }
public int [] invoiceNumber { get; set; }
public int [] customerPointer { get; set; }
public Customer(
string invoiceFormat,
int[] invoiceNumber,
int[] customerPointer)
{
this.invoiceFormat = invoiceFormat;
this.invoiceNumber = invoiceNumber;
this.customerPointer = customerPointer;
}
}
// How to assign value for invoiceNumber or customerPointer array in
// different windows form?
// The following codes is executed in windowsform 1
public static int iValue=0;
public static Customer []c = new Customer [9999];
c[iValue] = new Customer(textBox16.Text, invoiceNumber[0].iValue + 1,
customerPointer[0].iValue);
// I have an error that the name 'invoiceNumber and customerPointer'
// does not exist inthe current context
这是应该完成的:“invoiceNumber [0] .iValue + 1”? –
传入数组时,您传递的是数组的元素而不是数组本身。 invoiceNumber [0]表示数组的第一个元素。 invoiceNumber是数组 – Sorceri
System Down:这是计费系统。班级客户存储一系列发票号码。所以,在我的窗体中,当我加载帐单表单时。帐单表单访问客户类并将新的invoicenumber存储到数组中。所以我需要知道代码如何传递值数组invoiceNumber。 –