C# input validation, first digit must be 1? -
i want make sure user input 6 digits , start digit 1. how can make sure input start 1?
private static void getcustomerinfo(out string accnumberc) { string accnumberc; console.write("account number: "); accnumberc = console.readline(); if (accnumberc == "" || accnumberc.length < 6 || accnumberc.length > 6) { console.writeline("invalid data entered - no value redorded"); accnumberc = null; } }
if (string.isnullorempty(accnumberc) || accnumberc.length != 6 || !accnumberc.startswith("1")) { console.writeline("invalid data entered - no value redorded"); }
Comments
Post a Comment