Get Nth item from SelectList

I am trying to unit test a function that returns a SelectList.

How can I get an element from a SelectList to make sure my model is built correctly?

mySelectList.Items.First().DataValue

or something else.

+4
source share
1 answer

Just use mySelectList.ElementAt(n) to get the nth SelectListItem.

+9
source

All Articles