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

C#

 
QuestionCSS-cascading style sheet Pin
chubbie28-Dec-05 15:37
chubbie28-Dec-05 15:37 
AnswerRe: CSS-cascading style sheet Pin
[Marc]28-Dec-05 16:26
[Marc]28-Dec-05 16:26 
GeneralRe: CSS-cascading style sheet Pin
chubbie28-Dec-05 18:34
chubbie28-Dec-05 18:34 
QuestionUnique enumeration permutations... Pin
b33rdy28-Dec-05 13:36
b33rdy28-Dec-05 13:36 
AnswerRe: Unique enumeration permutations... Pin
Vega0228-Dec-05 15:34
Vega0228-Dec-05 15:34 
JokeRe: Unique enumeration permutations... Pin
b33rdy28-Dec-05 22:51
b33rdy28-Dec-05 22:51 
AnswerRe: Unique enumeration permutations... Pin
leppie28-Dec-05 19:04
leppie28-Dec-05 19:04 
AnswerRe: Unique enumeration permutations... Pin
FatGeek29-Dec-05 2:42
professionalFatGeek29-Dec-05 2:42 
This builds an ArrayList of all combinations of the enum, then dumps it to the console. This approach doesn't use recursion or ArrayList manipulation.

using System;
using System.Collections;

public class MyClass
{
    // enum MUST must have fewer entries than the width of an int - 1,
    // i.e. a maximum of 31 or 63 depending on CPU, but to be honest any more
    // than 16 is just silly!

    [Flags]
    enum testEnum
    {
        In,
        Out,
        Over,
        Hover
    }

    static void Main (string[] args) 
    {
        string[] names = Enum.GetNames (typeof (testEnum));
        ArrayList[] list = GetCombinations (names);

        foreach (ArrayList items in list)
            for (int i = 0, last = items.Count - 1; i <= last; i++)
                Console.Write (items [i] + (i < last ? ", " : "\n"));

        Console.ReadLine();
    }

    static ArrayList[] GetCombinations (string[] a)
    {
        int count = TwoPow (a.Length) - 1;
        ArrayList[] list = new ArrayList [count];

        for (uint i = 1; i <= count; i++)
        {
            ArrayList items = new ArrayList();

            for (uint j = 0, bits = i; bits != 0; j++, bits >>= 1)
                if ((bits & 1) != 0)
                    items.Add (a [j]);

            list [i - 1] = items;
        }
        
        return list;
    }

    static int TwoPow (int e)
    {
        int p = 1;
        for (int i = 0; i < e; i++)
            p <<= 1;

        return p;
    }
}


Fatgeek
Questionuninstall service and set up project Pin
geekpunk28-Dec-05 11:51
geekpunk28-Dec-05 11:51 
AnswerRe: uninstall service and set up project Pin
imsathy29-Dec-05 2:58
imsathy29-Dec-05 2:58 
GeneralRe: uninstall service and set up project Pin
geekpunk29-Dec-05 3:37
geekpunk29-Dec-05 3:37 
GeneralRe: uninstall service and set up project Pin
imsathy29-Dec-05 19:32
imsathy29-Dec-05 19:32 
QuestionHow to access static member?? Pin
jinzhecheng28-Dec-05 11:10
jinzhecheng28-Dec-05 11:10 
AnswerRe: How to access static member?? Pin
DavidNohejl28-Dec-05 12:06
DavidNohejl28-Dec-05 12:06 
Questionaccessing external applications thru code Pin
WetRivrRat28-Dec-05 10:34
WetRivrRat28-Dec-05 10:34 
Questioncurrentcell backcolor Pin
melanieab28-Dec-05 8:50
melanieab28-Dec-05 8:50 
AnswerRe: currentcell backcolor Pin
VPMahank29-Dec-05 6:46
VPMahank29-Dec-05 6:46 
GeneralRe: currentcell backcolor Pin
melanieab29-Dec-05 8:19
melanieab29-Dec-05 8:19 
Questionis scraping the right choice? Pin
JstDaNuGuy28-Dec-05 8:43
JstDaNuGuy28-Dec-05 8:43 
AnswerRe: is scraping the right choice? Pin
Dave Kreskowiak28-Dec-05 9:06
mveDave Kreskowiak28-Dec-05 9:06 
GeneralRe: is scraping the right choice? Pin
JstDaNuGuy28-Dec-05 9:08
JstDaNuGuy28-Dec-05 9:08 
GeneralRe: is scraping the right choice? Pin
kourvoisier28-Dec-05 20:25
kourvoisier28-Dec-05 20:25 
GeneralRe: is scraping the right choice? Pin
Michael P Butler29-Dec-05 0:27
Michael P Butler29-Dec-05 0:27 
QuestionSplitter problem Pin
VPMahank28-Dec-05 8:12
VPMahank28-Dec-05 8:12 
Questionicon loading page Pin
vandread128-Dec-05 6:06
vandread128-Dec-05 6:06 

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.