TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Turkalp Kucur
NA
50
19.1k
method for shuffling elements of an array
Oct 29 2012 5:50 AM
Hello my friends.
I need a method which takes an array of element than returns it with elements which are in randomized order.
For that purpose I developed following method
string[] shuffle(string[] a)
{
for (int i = 0; i < a.Length; i++)
{
string tmp = a[i];
int randomnumber = rnd.Next(i, a.Length);
a[i] = a[randomnumber];
a[randomnumber] = tmp;
}
return a;
}
but it returns sometimes the duplicate elements, which is wrong.
I need help.
Reply
Answers (
2
)
How to select toolStripSplitButton using keyboard shortcut?
how to make a bill using c#