0

          foreach (var i in credentials)
        {
            string line = i.ToString();
            if (i.ToString().Substring(0, i.ToString().IndexOf(":")).Equals(usernameInput.text) &&
                i.ToString().Substring(i.ToString().IndexOf(":") + 1).Equals(passwordInput.text))
            {   isExists = true;
                break;
            }
 }

this show error "length cant be less than zero.plz guide me how to put startindex and string length in this .

Vinay
  • 1
  • `i` doesn't contain a `:`. – Loocid Nov 24 '22 at 08:38
  • instead of substring you can directly check `if(line == $"{usernameInput.text}:{passwordInput.text}")` – Prasad Telkikar Nov 24 '22 at 08:38
  • 1
    Does this answer your question? [What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?](https://stackoverflow.com/questions/20940979/what-is-an-indexoutofrangeexception-argumentoutofrangeexception-and-how-do-i-f) – Yong Shun Nov 24 '22 at 08:42

0 Answers0