4
Answers

Index and length must refer to a location within the string.

Guest User

Guest User

6y
1.3k
1
  1. private bool isvalidyearcode(string ycode)  
  2.        {  
  3.            if (Convert.ToInt32(ycode.Substring(1, 4).ToString()) == 0 | Convert.ToInt32(ycode.Substring(3, 2).ToString()) + 1 != Convert.ToInt32(ycode.Substring(6, 7).ToString()) | Convert.ToInt32(ycode.Substring(5, 1)).ToString() != "-")  //error
  4.            {  
  5.                MessageBox.Show("Invalid Year code");  
  6.                return false;     
  7.            }          
  8.            return true;  
  9.        }  
Answers (4)