Mickeys
asked on
How do I check if the class it is empty?
I cant get this right. I need to know if there is something in my:
person.barnPnr[i]
but if I write person.barnPnr[i] and then . I can get a Count but that looks like Count< > so how do I check if there is something in it or not?
person.barnPnr[i]
but if I write person.barnPnr[i] and then . I can get a Count but that looks like Count< > so how do I check if there is something in it or not?
int i = 0;
//while (person.barnPnr[i]. > 0)
while(person.barnPnr.Count<int> != 0)
{
message = message + person.barnForNamn;
message = message + "\n";
message = message + person.barnEfterNamn;
message = message + "\n";
message = message + person.barnPnr;
i++;
}
Did you check person[i].barnPnr != 0 ?
Is barnPnr a List<>? Do you wish to iterate through it?
for (int i = 0; i < person.barnPnr.Count; i++)
{
YourObjectTypeHere barnPnr = person.barnPnr[i];
...
}
for (int i = 0; i < person.barnPnr.Count; i++)
{
YourObjectTypeHere barnPnr = person.barnPnr[i];
...
}
if ( person != null && person.barnPnr != null && person.barnPnr.Count > 0 )
{
// Your Logic... person.barnPnr[0]
}
{
// Your Logic... person.barnPnr[0]
}
ASKER
Dhaest:
while (person.barnPnr[i] != 0)
//error. Cant check string to int
-------------------------- ---------- -------
philipjonathan:
barnPnr is a public List<String> barnPnr;
for (int i = 0; i < person.barnPnr.Count; i++)
//error Error 1 Operator '<' cannot be applied to operands of type 'int' and 'method group' C:\Documents and Settings\MFL\Dokumenter\Vi sual Studio 2008\Projects\WebApplicati on1\WebApp lication1\ Class1.cs 37 33 WebApplication1
-------------------------- ---
HarryNS:
while(person.barnPnr != null)
works but I need to iterat throw the list util it is empty
/M
while (person.barnPnr[i] != 0)
//error. Cant check string to int
--------------------------
philipjonathan:
barnPnr is a public List<String> barnPnr;
for (int i = 0; i < person.barnPnr.Count; i++)
//error Error 1 Operator '<' cannot be applied to operands of type 'int' and 'method group' C:\Documents and Settings\MFL\Dokumenter\Vi
--------------------------
HarryNS:
while(person.barnPnr != null)
works but I need to iterat throw the list util it is empty
/M
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked. Thx