IndexOfAny( )
and
LastIndexOfAny( )
. These search for the first or last character that matches any of a set of
characters. Here are their simplest forms:
public int IndexOfAny(char[ ]
a
)
public int LastIndexOfAny(char[ ]
a
)
IndexOfAny( )
returns the index of the first occurrence of any character in
a
that is found
within the invoking string.
LastIndexOfAny( )
returns the index of the last occurrence of any
character in
a
that is found within the invoking string. Both return –1 if no match is found.
When working with strings, it is often useful to know if a string begins with or ends
with a given substring. To accomplish these tasks, use the
StartsWith( )
and
EndsWith( )
methods. Here are their two simplest forms:
public bool StartsWith(string
str
)
public bool EndsWith(string
str
)
Do'stlaringiz bilan baham: |