Rod
Rod

Reputation: 15457

indexOf finds empty string

I got a positive result when ctrl.Text happened to be an empty string (value was 0)

Is that the correct behavior? Do I need to check for an empty string?

"Next|Prev|First|Last|Search".IndexOf(ctrl.Text) > -1

Upvotes: 3

Views: 2632

Answers (1)

dowhilefor
dowhilefor

Reputation: 11051

Yes, in the msdn you will find.

if value is String.Empty, the return value is 0.

Upvotes: 12

Related Questions