i want to creat a program in c# in which user will enter a string like
BC12054321 as argument in a method.
BC (first two characters from left) will show its Bachelor, It can MC to represents MCS.
12 (3rd and 4th characters from left) represent enrollment year which cannot be more than 2015 and less than 2012)
04 (5th and 6th characters from left) represents enrolled semester. it can be 02 or 04 now 02 will represent Spring semester and 04 will represent Fall semester
54321 (last 5 characters) represents student unique id.
this is the whole case now I am confuse weather I use array to store that string or simple variable. if I use simple variable then how could I apply these all constraint in a single variable I mean how can I split this string to check all the conditions. can any body help me? I also attached that what I actually want to do please see the gif picture :
Store user input into a variable, then use
Substring to split each value out to separate variables.
string studentInfo = Console.ReadLine(); string studentProgram = studentInfo.Substring(0, 2); string studentYearOfEnrollment = studentInfo.Substring(2, 2); string studentSemester = studentInfo.Substring(4, 2); string studentID = studentInfo.Substring(6, 5);