I have one class as below:
public class test
{
int i;
string str;
Socket s;
DateTime dt;
}
and am creating object of this class as below
public void collection()
{
test t1=new test{i=1,str="string1", s=soc1, dt=DateTime.Today() };
test t2=new test{i=2,str="string2", s=soc2, dt=DateTime.Today() };
test t3=new test{i=3,str="string3", s=soc3, dt=DateTime.Today() };
ArraList a=new ArrayList();
a.Add(t1);
a.Add(t2);
a.Add(t3);
}
and am adding all these objects(t1,t2,t3) into an array. Now, how can i get all socket members in object array using linq???
I think you should cast your ArrayList to a collection of type ‘test’
so
Will give you the result.
Or if you think your ArrayList might also contain other types of obejct, you can use
Note: Make sure Socket is a publicly accessible property and depending on the framework you use, consider using a Generic collection