Hi
There are some fixed no of text string
say :
public const string Str1 = "Text1";
public const string Str2 = "Text2";
.......
In the aspx page, there is a submit button. When user clicks it, a text message will be selected randomly to display as a label from those text string.
How should I write that random selection part of the C# code?
Thanks
Loading
Vimal KandasamyPosted Apr 10, 2009, 2:54 AM
I have one idea
Store All your Strings in an array...
like
String[] ar={"hi","bye","a","b"};
then add below code in submit button
Random myrandom = new Random();
int index = myrandom.Next(0,ar.Length);
String ranStr=ar[index];
ranstr will contain random String...
try this...
jayanand kamblePosted Apr 10, 2009, 4:47 AM
it works...