Click here to Skip to main content
15,887,952 members
Home / Discussions / C#
   

C#

 
Questionruntime error Pin
n.nili13-May-13 19:04
n.nili13-May-13 19:04 
AnswerRe: runtime error Pin
Pete O'Hanlon13-May-13 21:22
mvePete O'Hanlon13-May-13 21:22 
AnswerRe: runtime error Pin
dusty_dex13-May-13 22:20
dusty_dex13-May-13 22:20 
Questionstring concatenation with all possibilities Pin
sethupathiram13-May-13 3:19
sethupathiram13-May-13 3:19 
AnswerRe: string concatenation with all possibilities Pin
Pete O'Hanlon13-May-13 3:30
mvePete O'Hanlon13-May-13 3:30 
AnswerRe: string concatenation with all possibilities Pin
Simon_Whale13-May-13 3:38
Simon_Whale13-May-13 3:38 
AnswerRe: string concatenation with all possibilities Pin
PIEBALDconsult13-May-13 4:33
mvePIEBALDconsult13-May-13 4:33 
AnswerRe: string concatenation with all possibilities Pin
Richard Deeming13-May-13 5:06
mveRichard Deeming13-May-13 5:06 
Something like this should work:
C#
static IEnumerable<T[]> BuildCombinations<T>(T[] input)
{
   int length = input.Length;
   int max = checked(1 << length);

   // Skip the first item, which would be completely empty.
   // (If you want this item, start at zero.)

   for (int combination = 1; combination < max; combination++)
   {
      var current = new T[length];

      for (int index = 0, bit = 1; index < length; index++, bit <<= 1)
      {
         if ((combination & bit) != 0)
         {
            current[index] = input[index];
         }
      }

      yield return current;
   }
}

...
string pattern = " INC | TRUST | COMPANY | 401K ";
string[] ArrPattern = pattern.Split('|');
List<string[]> allCombinations = BuildCombinations(ArrPattern);




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


AnswerRe: string concatenation with all possibilities Pin
Anna King14-May-13 2:56
professionalAnna King14-May-13 2:56 
QuestionError 1 The type or namespace name 'Form1' Pin
Topias Jäppilä13-May-13 2:06
Topias Jäppilä13-May-13 2:06 
QuestionRe: Error 1 The type or namespace name 'Form1' Pin
Richard MacCutchan13-May-13 2:39
mveRichard MacCutchan13-May-13 2:39 
AnswerRe: Error 1 The type or namespace name 'Form1' Pin
Topias Jäppilä13-May-13 4:44
Topias Jäppilä13-May-13 4:44 
GeneralRe: Error 1 The type or namespace name 'Form1' Pin
Richard MacCutchan13-May-13 5:02
mveRichard MacCutchan13-May-13 5:02 
GeneralRe: Error 1 The type or namespace name 'Form1' Pin
Topias Jäppilä13-May-13 5:08
Topias Jäppilä13-May-13 5:08 
GeneralRe: Error 1 The type or namespace name 'Form1' Pin
Richard MacCutchan13-May-13 5:18
mveRichard MacCutchan13-May-13 5:18 
AnswerRe: Error 1 The type or namespace name 'Form1' Pin
Simon_Whale13-May-13 4:51
Simon_Whale13-May-13 4:51 
AnswerRe: Error 1 The type or namespace name 'Form1' Pin
Anna King14-May-13 3:14
professionalAnna King14-May-13 3:14 
QuestionRegarding Display data. Pin
nagesh2112-May-13 23:49
nagesh2112-May-13 23:49 
AnswerRe: Regarding Display data. Pin
Richard MacCutchan13-May-13 0:05
mveRichard MacCutchan13-May-13 0:05 
GeneralRe: Regarding Display data. Pin
nagesh2113-May-13 0:37
nagesh2113-May-13 0:37 
GeneralRe: Regarding Display data. Pin
Richard MacCutchan13-May-13 0:40
mveRichard MacCutchan13-May-13 0:40 
GeneralRe: Regarding Display data. Pin
nagesh2113-May-13 0:44
nagesh2113-May-13 0:44 
GeneralRe: Regarding Display data. Pin
Pete O'Hanlon13-May-13 1:33
mvePete O'Hanlon13-May-13 1:33 
AnswerRe: Regarding Display data. Pin
Abhinav S13-May-13 19:53
Abhinav S13-May-13 19:53 
SuggestionReview: CLR via C# Book Pin
Mohammed Hameed12-May-13 23:19
professionalMohammed Hameed12-May-13 23:19 

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.