File1에서는 3 개의 문자열이있는 클래스를 만들었습니다. 나는 공공 arraylist와 다른 수업을 만들었습니다. 이 arraylist가 동적 이길 원하고 그 안에 들어있는 객체가 3 개의 문자열을 가진 클래스입니다. 파일의 클래스 멤버에 액세스 할 수 있지만 별도의 파일에는 액세스 할 수 없습니다.arraylist 공개는 어떻게합니까?
파일 1
public class SensorCollection
{
public string ipAddress;
public string portNumber;
public string physicalLocation;
public DetectorCollection(string ipAddr, string portNum, string loc)
{
this.ipAddress = ipAddr;
this.portNumber = portNum;
this.physicalLocation = loc;
}
}
public class SensorCollectionArray
{
public System.Collections.ArrayList SensorArrayList;
}
...
System.Collections.ArrayList DetectorArrayList = new System.Collections.ArrayList();
...
DetectorArrayList.Add(new DetectorCollection(ipAddress, portNum, str));
그래서 나는 클래스의 배열을 채울 수 있지만 별도의 파일에 액세스 할 수 없습니다. 파일 2
AdvancedSettingsForm.SensorCollectionArray mainDetectorCollectionArray;
System.Collections.ArrayList arrList;
코드를 컴파일 할 수 없습니다. 당신의 생성자는'DetectorCollection'이지만 당신의 클래스는'SensorCollection'입니다. –
파일이 동일한 네임 스페이스입니까? –
당신은 .net 1.x에 있습니까? 아니면 왜'List'대신'ArrayList'를 사용하고 있습니까? –
CodesInChaos