P
Peter
Marin said:I have a structur in a class level like this
public struct sunData
{
public int location;
public string url_address;
public string mac_address;
}
..........................
Inside one of the methods in the class I use a LiatArray like this
ArrayList SunsCollection = new ArrayList();
and I assin the following 3 values inside a loop and it works fine.
sunData sundata;
sundata.location = (int)SunsdataRow["LOCATION"];
sundata.url_address = SunsdataRow["IP_ADDRESS"].ToString();
sundata.mac_address = SunsdataRow["MAC_ADDRESS"].ToString();
// add to the ListArray collection
SunsCollection.Add(sundata);
Problem is that I can't print the data from the listarray into a
consol or a logger like this
Console.WriteLine(SunsCollection[0].url_address );
I get a the following error
Error 80 'object' does not contain a definition for 'location'
Can someone help me please?
Reagrds
Marin
You would need to cast the object you get from the ArrayList to the
type you need. For example:
string address = ((SunData)sunsCollection[0]).UrlAddress;
Or use a List<SunData>.
For example:
using System.Collections.Generic;
List<SunData> sunsList = new List<SunData>();
// add some SunData objects to the list...
string address = sunsList[0].UrlAddress;
/Peter
--