Click here to Skip to main content
15,917,177 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
Pls i want to design a windows form application using C# that distributes names into different tables without repetition and randomly so i want to knw how to write a random distribution class
Am new to programming so i dont know how to go about this
Thanks
Posted
Comments
Peter_in_2780 31-Jul-12 3:57am    
Ask your question ONCE. Do not crosspost.

The Random class lets you generate random numbers all day long.
 
Share this answer
 
Create a bucket of the things you want to distribute randomly and pull things out one at a time.

In code - create a List<yourthing> and populate it with everything you wish to distribute. Use the Random class to pick a number between 0 and the number of things in the list (-1). Get the value and remove the item then repeat until the list is empty.
 
Share this answer
 
v3
Comments
CPallini 31-Jul-12 5:24am    
Good one.
If you need to extract random numbers (might be the indices of your array of names) without repetitions then have a look at my tip "Random extraction of 5 cards from a deck"[^] (it is C++ code, I know, but, anyway, just the algo matters).
 
Share this answer
 
based on my understanding i think you want to assign value to veriables from one form and retrieve on multiple forms
there are several ways to achieve this functionality..

simplest of those is to create a static class. may you name it as Common.cs and declare all of your veriables into that class and access them in all of the class, inside project scope, by following way

C#
namespace.ClassName.VeriableName

i.e

Form1 =>
C#
yourProjName.Common.FirstVar = "Hello";

Form2 =>
C#
MessageBox.Show(yourProjName.Common.FirstVar); //it will pop up HELLO


hope it will help you
 
Share this answer
 
Comments
bbnmmn 1-Aug-12 6:55am    
Its a very large database that accepts names of all graduates per year in different schools in the country, am suppose to design an app that distributes this graduates to 36 different states without repeating a name
Zubair Alie 2-Aug-12 2:46am    
assign them an alias

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900