mardi 31 mars 2015

C# random choice if result

I am trying to code a random choice script in C# for example something like this:



foo = ['a', 'b', 'c']
result = random.choice(foo)

if result == "a":
webBrowser1.Navigate("http://www.google.com/");
if result == "b":
webBrowser1.Navigate("http://www.yahoo.com/");
if result == "c":
webBrowser1.Navigate("http://www.bing.com/");


The random script example above is in Python but don't know how to make a similar script like it in C# and couldn't find out how to do it by goggling my problem. If anyone knows how to code a random if result to randomly pick which code to run, please share. Thanks in Advance!





Aucun commentaire:

Enregistrer un commentaire