C
codymanix
I have a class Customer. A customer can have multiple accounts. The
account-data is hold internally in a datatable but this implementation
detail should be hidden from the user of the class customer.
the user of the class customer should be able to use foreach on
customer.Accounts and can do a customer.Accounts.Count. indexing should not
be neccessary because the order is not important.
How can I accomplish this? I cannot use IList and its derivats because they
are not readonly also the readonly IList-wrapperclasses throw a exception if
somebody tries to modifiy them but I want to catch that with the compiler!
public class Customer
{
public <whatever> Accounts
{
get
{
return <whatever>
}
}
}
public class Account
{
}
account-data is hold internally in a datatable but this implementation
detail should be hidden from the user of the class customer.
the user of the class customer should be able to use foreach on
customer.Accounts and can do a customer.Accounts.Count. indexing should not
be neccessary because the order is not important.
How can I accomplish this? I cannot use IList and its derivats because they
are not readonly also the readonly IList-wrapperclasses throw a exception if
somebody tries to modifiy them but I want to catch that with the compiler!
public class Customer
{
public <whatever> Accounts
{
get
{
return <whatever>
}
}
}
public class Account
{
}