c# - Use a "null" switch statement to determine if a range of TextBoxes are null, instead of using if-else statements -
Right now, I am trying to write the method that has a switch statement that is used as a "trigger" The reason that the reserved word tap is because I want to test all the text boxes, for this pointless state of the switch statement, and if they are, then a message dialog (which I have coded for each box) You can say that you can not leave ' The name of the box here is "blank, you must enter text". In short, it is possible to use a switch statement to check if a bunch of text boxes is void (malfunctional) if-else Instead of using the whole sequence of statements, if so, how? (Please)
I should say that I was doing this problem for the last hour, no success was found. / P>
Any help accepted from the heart
If you specifically , then create them in the then again via the textbox collection. It will be repeated through the archive, and after that each string will be tested. I will not recommend doing this, unless values of all text boxes are to be validated for many situations, all are the same , in which case each string If the value is to be more prominent then. If you want quick one line solution to check it for each one, you can use it: switch :
list or in an
array , if it is not already so.
list & lt; String & gt; Text box compilation = new list & lt; String & gt; (); TextBoxCollection.Add (yourTextBoxStringValue); // Do this for each box
foreach (string text content in text box content) {switch (text content) {case faucet: {// message error is here breakdown; } "Other Requirements": {// Other items are available here; } "Another requirement": case "one more requirement": {// different things here, maybe? break; }}}
if (string.IsNullOrWhiteSpace ( YourTextBox.Text)) {// throw error}
Comments
Post a Comment