Link to home
Start Free TrialLog in
Avatar of Pit76
Pit76Flag for Belgium

asked on

How to check if a list contains items? c#

HI all,

I have a list wich I need to check if it contains any items or not. If it does not I need to show a warning that it has to have at least one item.

How to check this?
Probably pretty simple but can't seem to find it right now...

Grts
Avatar of kaufmed
kaufmed
Flag of United States of America image


List<string> someList = new List<string>();
 
someList.Count > 0

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of wht1986
wht1986
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pit76

ASKER

Hi,

Indeed I forgot to tell that. It's the first one.
Thought it was going to be simple, about the same as checking if a DataSet has rows...

Anyway thx for putting my nose on it :)

Grts
Avatar of Pit76

ASKER

Thx :)
Wow...  I don't even know what to say.
Avatar of Pit76

ASKER

Yeah I know sry.
 I should have split the points but tbh I looked over your answer, as stupid as it may sound...

You've helped me before so I feel a little bad about it...

Greetings.