strings

  • Thread starter Thread starter juli jul
  • Start date Start date
J

juli jul

Hello ,
wanted to know if it's possible to create a set (enum or array) of
strings and than make the IndexOf method on it.
I have 6 strings and I want to chack if the string I read is one of them
(with IndexOf!=-1)
How to do it the best?
Thanks a lot
 
juli jul said:
wanted to know if it's possible to create a set (enum or array) of
strings and than make the IndexOf method on it.
I have 6 strings and I want to chack if the string I read is one of them
(with IndexOf!=-1)
How to do it the best?

Yes, just create a string array and then use the static Array.IndexOf
method. Alternatively, put them in an ArrayList and use the instance
method ArrayList.IndexOf.
 
I am doing it in if with all the strings,could it slow down the
performance or it supposed to be the same as with an array?
 
juli jul said:
I am doing it in if with all the strings,could it slow down the
performance or it supposed to be the same as with an array?

I'm not entirely sure what you're asking - are you asking if the
performance of Array.IndexOf is the same as ArrayList.IndexOf? If so, I
suspect the difference (if any) is going to be negligible compared with
most other aspects of your program.
 
Back
Top