nassss

Untitled

Jan 11th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. public static int IndexOf(string str, char value)
  2. {
  3. if (str == null || value == '\u0000')
  4. {
  5. throw new ArgumentNullException("Input cannot be empty. Please try again!");
  6. }
  7.  
  8. else
  9. {
  10. int position = 0;
  11.  
  12. for (int i = 0; i < str.Length; i++)
  13. {
  14. if (value == str[i])
  15. {
  16. position = i;
  17. return position;
  18. }
  19. }
  20. return -1;
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment