c# - Per-String function (IDK how it's called) -


i'm working on c# project, , need this, without if, in short way;

for (string = n) (string = s) (string = c) 

i don't know how it's called, or how without long if functions.

you can use switch statement:

switch (mystring) {     case "n":         //...         break;     case "s":         //...         break;     case "c":         //...         break; } 

but aware used case-strings constants , case-sensitive!
aware using mystring.tolower() dangerous!

if case-sensivity problem, have use ifs:

if (string.compare(mystring, "abc", true)==0)) {     //... } else if (string.compare(mystring, "123", true)==0)) {     //... } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -