c# - ReadLine issues -
I need to create a console application in C # which will take numbers and lines
X any number
xxxx-xx-xxxxxx
or 4 numbers, row, 2 numbers, row, 6 number
The suggested user input and confirm that the user has not entered the integer at the right places and has not replaced the rows.
I want to put it in a format so that the user has to write the lines themselves.
I think the lines are automatically inserted, so users do not want to take them, the length of the string is also always the same. (0-13 or 14 characters)
Can it be done in any simple way?
edit : I wrote and added the code instead, instead it has to be all here) This code takes string input and ensures That no invalid characters were entered, in other words it works, but I want to give the place to the program '-' where they should be done automatically in any way and it will also be good that you To limit the number of (14 to lake , Including lines). My primary point is that '-' should be able to stay automatically automatically, while still able to use backspace. Sorry if the code is primitive, this is a school project and I am still learning. This is the method that "I want" to use. You can try to do something like that (string of length 14 for hardcod, position 4 and 7 with a dash) it will stop all input from the user and check whether it is a digit or not. If it is a digit, it is printed and adds it to the input, in addition, it will print a dash when the length of the input will reach some point.
string input = ""; While (InputLange <14) {char c = Console.ReadKey (true) KEKER; If (c> = 48 & amp; amp; amp; amp; c & lt; = 57) // ASCII code for one digit (between 0 and 9) {input + = c; // Add points for the input console. Write (C); // output it in the console} if (input length == 4 || input. Length == 7) {input + = "-"; Console.Write ("-"); // Add a dash to the input and type it for the console}}
Comments
Post a Comment