c# - Conditional MessageBoxes -


i'm making script display particular messageboxes if different conditions fulfilled. i have 8 conditions check , each of them have display different messageboxes if "0" or "1".

an shortened example of code follows:

// similar if(y[1] == "1") statements above similar messages without corresponding fruit(s)  if (y[2] == "1") { messagebox.show("multiple goods required! please following                    items off shelves" + environment.newline +                    "1. apple" + environment.newline + "2. pear" +                    environment.newline + "3. orange"); }  else if (y[2] == "0") { messagebox.show("multiple goods required! please following                    items off shelves" + environment.newline +                    "1. apple" + environment.newline + "2. pear"); } 

my knowledge of c# quite basic, i'm willing learn! please help!

i make messages conditionally, , write code showing message box once:

string msg = "multiple goods required! please following items off shelves";  if(y[2] == "0" || y[2] == "1") {     msg += environment.newline + "1. apple"             + environment.newline + "2. pear";      if (y[2] == "1")         msg += environment.newline + "3. orange";      messagebox.show(msg); } 

i made above equivalent code, otherwise think written better.

also consider using string.format , stringbuilder creating message, instead of concatenating small strings.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -