Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why flags (bool type variables) not recommended in programming? Pin
Nagy Vilmos30-Oct-08 23:11
professionalNagy Vilmos30-Oct-08 23:11 
QuestionManually add data to datagrid combobox in C# Pin
Brad Wick30-Oct-08 9:28
Brad Wick30-Oct-08 9:28 
AnswerRe: Manually add data to datagrid combobox in C# Pin
Sami Sammour31-Oct-08 1:32
Sami Sammour31-Oct-08 1:32 
GeneralRe: Manually add data to datagrid combobox in C# Pin
Brad Wick31-Oct-08 4:19
Brad Wick31-Oct-08 4:19 
GeneralRe: Manually add data to datagrid combobox in C# Pin
Sami Sammour31-Oct-08 6:43
Sami Sammour31-Oct-08 6:43 
GeneralRe: Manually add data to datagrid combobox in C# Pin
Brad Wick31-Oct-08 7:35
Brad Wick31-Oct-08 7:35 
Questionchristmas exchange list generator Pin
aei_totten30-Oct-08 9:12
aei_totten30-Oct-08 9:12 
AnswerRe: christmas exchange list generator Pin
Ben Fair30-Oct-08 9:52
Ben Fair30-Oct-08 9:52 
If you want it to be more random you could use your original idea but with a random number generator to determine which array to look at rather than just selecting the longest array. Another idea would be to put everything in a single array and just use the random number generator to give a random index into the array and if the item in the index is in a different family, you've got a hit otherwise get another index from the random number generator.

List<int> peopleUsed = new List<int>();
Random r = new Random();
int person1Index, person2Index;
person1Index = person2Index = 0;
while(peopleUsed.Count < people.Length) // people is the array of people
{
    if(!peopleUsed.Contains(person1Index)) // make sure person1Index hasn't been used
    {
        // find a person2Index that hasn't been used
        do
        {
            person2Index = r.Next(0, people.Length);
        }
        while(peopleUsed.Contains(person2Index) && !peopleAreInSameFamily(person1Index, person2Index)); // also make sure they aren't in the same family!
        // DO SOMETHING WITH THE 2 PEOPLE
        peopleUsed.AddRange(new int[] { person1Index, person2Index }); // add the two person indexes to our used list
    }
    person1Index++;
}


Keep It Simple Stupid! (KISS)

GeneralRe: christmas exchange list generator Pin
aei_totten30-Oct-08 10:01
aei_totten30-Oct-08 10:01 
Questionhow to Open compressed TIF (JTIF) within WinForm and C# Pin
ImNAM30-Oct-08 7:29
ImNAM30-Oct-08 7:29 
AnswerRe: how to Open compressed TIF (JTIF) within WinForm and C# Pin
Dave Kreskowiak30-Oct-08 8:09
mveDave Kreskowiak30-Oct-08 8:09 
GeneralRe: how to Open compressed TIF (JTIF) within WinForm and C# Pin
Dan Neely30-Oct-08 8:56
Dan Neely30-Oct-08 8:56 
GeneralRe: how to Open compressed TIF (JTIF) within WinForm and C# Pin
Dave Kreskowiak30-Oct-08 15:56
mveDave Kreskowiak30-Oct-08 15:56 
GeneralRe: how to Open compressed TIF (JTIF) within WinForm and C# Pin
Dan Neely31-Oct-08 2:03
Dan Neely31-Oct-08 2:03 
Questionclosed dialog (from other thread) minimizes application - need some help please !!! Pin
Skeletor2330-Oct-08 7:00
Skeletor2330-Oct-08 7:00 
AnswerRe: closed dialog (from other thread) minimizes application - need some help please !!! Pin
jas0n232-Nov-08 1:53
jas0n232-Nov-08 1:53 
QuestionSecurity in a C# based Desktop Application Pin
mdwhite7630-Oct-08 6:07
mdwhite7630-Oct-08 6:07 
AnswerRe: Security in a C# based Desktop Application Pin
Simon P Stevens30-Oct-08 6:32
Simon P Stevens30-Oct-08 6:32 
AnswerRe: Security in a C# based Desktop Application Pin
Giorgi Dalakishvili30-Oct-08 8:30
mentorGiorgi Dalakishvili30-Oct-08 8:30 
QuestionProblem of Unloading Managed C++ DLL... Pin
chandrap30-Oct-08 5:57
chandrap30-Oct-08 5:57 
QuestionRe: Problem of Unloading Managed C++ DLL... Pin
Mark Salsbery30-Oct-08 7:29
Mark Salsbery30-Oct-08 7:29 
AnswerRe: Problem of Unloading Managed C++ DLL... Pin
chandrap30-Oct-08 7:32
chandrap30-Oct-08 7:32 
GeneralRe: Problem of Unloading Managed C++ DLL... Pin
chandrap30-Oct-08 7:44
chandrap30-Oct-08 7:44 
GeneralRe: Problem of Unloading Managed C++ DLL... Pin
Mark Salsbery30-Oct-08 7:53
Mark Salsbery30-Oct-08 7:53 
GeneralRe: Problem of Unloading Managed C++ DLL... Pin
chandrap30-Oct-08 8:13
chandrap30-Oct-08 8:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.