Click here to Skip to main content
15,914,447 members
Home / Discussions / C#
   

C#

 
QuestionRegarding Setting Registry Value Pin
A.Grover28-Dec-05 20:21
A.Grover28-Dec-05 20:21 
AnswerRe: Regarding Setting Registry Value Pin
Judah Gabriel Himango29-Dec-05 4:37
sponsorJudah Gabriel Himango29-Dec-05 4:37 
AnswerRe: Regarding Setting Registry Value Pin
Dave Kreskowiak29-Dec-05 5:47
mveDave Kreskowiak29-Dec-05 5:47 
QuestionWhen adding refrences to other dll's...... Pin
kourvoisier28-Dec-05 20:20
kourvoisier28-Dec-05 20:20 
AnswerRe: When adding refrences to other dll's...... Pin
imsathy28-Dec-05 22:25
imsathy28-Dec-05 22:25 
AnswerRe: When adding refrences to other dll's...... Pin
Dave Kreskowiak29-Dec-05 5:44
mveDave Kreskowiak29-Dec-05 5:44 
Questionhow to capture file name opened by the user in a PC Pin
m_mazhar28-Dec-05 19:36
m_mazhar28-Dec-05 19:36 
AnswerRe: how to capture file name opened by the user in a PC Pin
Dave Kreskowiak29-Dec-05 5:42
mveDave Kreskowiak29-Dec-05 5:42 
QuestionHow can I get my project directory? Pin
tiancaidao28-Dec-05 17:58
tiancaidao28-Dec-05 17:58 
AnswerRe: How can I get my project directory? Pin
S. Senthil Kumar28-Dec-05 19:31
S. Senthil Kumar28-Dec-05 19:31 
GeneralRe: How can I get my project directory? Pin
tiancaidao28-Dec-05 19:52
tiancaidao28-Dec-05 19:52 
GeneralRe: How can I get my project directory? Pin
S. Senthil Kumar29-Dec-05 2:37
S. Senthil Kumar29-Dec-05 2:37 
QuestionUnable to direct Data Source location after published Pin
bc111828-Dec-05 17:25
bc111828-Dec-05 17:25 
QuestionHelp for breakpoint event. Pin
tiancaidao28-Dec-05 17:24
tiancaidao28-Dec-05 17:24 
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 

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.