• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Collections Help when in a parent class

S

scott ocamb

#1
All,

I have a Form Class, shown below that will have a collection of Question
objects.

The Question Class has an Approve method.

When any single Question is approved, I need to know if all Questions in the
Collection in the Form are approved.

A single Question does not know about the collection it is part of in the
form.

Any impelemtation suggestions would be appreciated.

public class Form

{

private List<Question> _questions = new List<Question>();

}
 
C

Cor Ligthert[MVP]

#2
scott,

That is exactly for what the for and foreach methods are.

You can use Linq as well to select all not approved questions and if that
returns null you know that it is done.

(I would use a simple foreach in this case, behind the scene it will be sure
be used by Linq)

Cor

"scott ocamb" <socamb@xxxxxx> schreef in bericht
news:uz37qCvtIHA.1220@xxxxxx

> All,
>
> I have a Form Class, shown below that will have a collection of Question
> objects.
>
> The Question Class has an Approve method.
>
> When any single Question is approved, I need to know if all Questions in
> the Collection in the Form are approved.
>
> A single Question does not know about the collection it is part of in the
> form.
>
> Any impelemtation suggestions would be appreciated.
>
> public class Form
>
> {
>
> private List<Question> _questions = new List<Question>();
>
> }
>
>
>
>