I have the following code in C# and I am trying to find out why I am not able to access from a subclass that is from type list the elements of a class address. This is the code
MemberList list = MemberDB.GetMembers("sql", m_page,
m_RecordPerPage, out count, _state);
/*******************************/
public static MemberList GetMembers(string sql, int page,
int pageSize, out int count, string parState)
{
MemberList retval = new MemberList();
SqlParameter pOut = new SqlParameter("@Count", SqlDbType.Int, 4);
pOut.Direction = ParameterDirection.Output;
SqlParameter[] param = new SqlParameter[]{
new SqlParameter("@Sql", sql),
new SqlParameter("@parState", parState),
new SqlParameter("@Page", page),
new SqlParameter("@PageSize", pageSize),
pOut };
using (SqlDataReader reader = SqlHelper.ExecuteReader(
Helper.ConnectionString, CommandType.StoredProcedure,
"[app_Member_Search]", param))
{
while (reader.Read())
//if (reader.Read())
{
retval.Add(Read(reader));
//retval = Read(reader);
}
}
count = Helper.ToInt32(pOut.Value);
return retval;
}
public class Member
{
private Address m_address;
public Address Address
{
get { return m_address; }
set { m_address = value; }
}
public Member()
{
m_address = new Address();
}
}
public class MemberList : List<Member>
{
public MemberList() { }
}
case "Address":
retval.Address.Address1 = Helper.ToString(reader[i]);
//throw new Exception(Helper.ToString(reader[i]));
//retval.Address1 = Helper.ToString(reader[i]);
break;
case "Address2":
retval.Address.Address2 = Helper.ToString(reader[i]);
//retval.Address2 = Helper.ToString(reader[i]);
break;
case "City":
retval.Address.City = Helper.ToString(reader[i]);
//retval.City = Helper.ToString(reader[i]);
break;
case "State":
retval.Address.State = Helper.ToString(reader[i]);
//retval.State = Helper.ToString(reader[i]);
break;