Click here to Skip to main content
15,905,587 members
Home / Discussions / C#
   

C#

 
QuestionStoring memory address as hex in an xml file Pin
Jordanwb23-Oct-09 12:40
Jordanwb23-Oct-09 12:40 
AnswerRe: Storing memory address as hex in an xml file Pin
Christian Graus23-Oct-09 13:09
protectorChristian Graus23-Oct-09 13:09 
GeneralRe: Storing memory address as hex in an xml file Pin
Jordanwb23-Oct-09 13:15
Jordanwb23-Oct-09 13:15 
AnswerRe: Storing memory address as hex in an xml file Pin
PIEBALDconsult23-Oct-09 17:46
mvePIEBALDconsult23-Oct-09 17:46 
Generalcan you help me to do this question Pin
Member 665675323-Oct-09 22:17
Member 665675323-Oct-09 22:17 
GeneralRe: can you help me to do this question Pin
nagendrathecoder23-Oct-09 22:29
nagendrathecoder23-Oct-09 22:29 
GeneralRe: can you help me to do this question Pin
Christian Graus23-Oct-09 22:43
protectorChristian Graus23-Oct-09 22:43 
GeneralRe: can you help me to do this question Pin
Lutosław24-Oct-09 1:29
Lutosław24-Oct-09 1:29 
GeneralRe: can you help me to do this question Pin
Pete O'Hanlon24-Oct-09 9:48
mvePete O'Hanlon24-Oct-09 9:48 
QuestionCapturing key presses or key strokes Pin
AndyASPVB23-Oct-09 9:16
AndyASPVB23-Oct-09 9:16 
AnswerRe: Capturing key presses or key strokes Pin
OriginalGriff23-Oct-09 9:28
mveOriginalGriff23-Oct-09 9:28 
GeneralRe: Capturing key presses or key strokes Pin
Lutosław23-Oct-09 9:57
Lutosław23-Oct-09 9:57 
GeneralRe: Capturing key presses or key strokes Pin
AndyASPVB23-Oct-09 10:49
AndyASPVB23-Oct-09 10:49 
GeneralRe: Capturing key presses or key strokes Pin
Anthony Mushrow23-Oct-09 16:54
professionalAnthony Mushrow23-Oct-09 16:54 
AnswerRe: Capturing key presses or key strokes Pin
Henry Minute23-Oct-09 12:38
Henry Minute23-Oct-09 12:38 
GeneralRe: Capturing key presses or key strokes Pin
Rajesh R Subramanian23-Oct-09 23:10
professionalRajesh R Subramanian23-Oct-09 23:10 
GeneralRe: Capturing key presses or key strokes Pin
Henry Minute25-Oct-09 1:10
Henry Minute25-Oct-09 1:10 
GeneralRe: Capturing key presses or key strokes Pin
Rajesh R Subramanian25-Oct-09 1:55
professionalRajesh R Subramanian25-Oct-09 1:55 
GeneralRe: Capturing key presses or key strokes Pin
Henry Minute25-Oct-09 4:40
Henry Minute25-Oct-09 4:40 
AnswerRe: Capturing key presses or key strokes Pin
Rajesh R Subramanian23-Oct-09 23:06
professionalRajesh R Subramanian23-Oct-09 23:06 
QuestionSending a command to an IEnumerable method Pin
Lutosław23-Oct-09 9:13
Lutosław23-Oct-09 9:13 
AnswerRe: Sending a command to an IEnumerable method Pin
Ian Shlasko23-Oct-09 9:55
Ian Shlasko23-Oct-09 9:55 
Ok, my brain is kind of winding down, it being Friday and all, so I can't quite wrap it around your algorithm right now... But for skipping entries in the enumeration itself...

Basically, foreach is a shortcut for a more wordy but not very complicated code block:
IEnumerator<int[]> en = GetPermutations().GetEnumerator()
while (en.MoveNext())
{
  int[] permutation = en.Current;

  // Your code
}

If you write this out yourself, you have a reference to the enumerator, so you can do this:
public bool SkipPermutations(IEnumerator en, int count)
{
  for(;count > 0; count--)  // Note the initial semicolon - Don't need to initialize
    if (!en.MoveNext()) return false;

  return true;
}

Then you can just put this in the middle of your foreach:
if (!SkipPermutations(en, 4)) break;

The trick, of course, is that if you skip past the end of the enumeration, you'll get an exception... So you have to keep checking to see if you're at the end.

Proud to have finally moved to the A-Ark. Which one are you in?
Developer, Author (Guardians of Xen)

GeneralRe: Sending a command to an IEnumerable method Pin
Lutosław23-Oct-09 10:27
Lutosław23-Oct-09 10:27 
GeneralRe: Sending a command to an IEnumerable method Pin
Ian Shlasko23-Oct-09 10:38
Ian Shlasko23-Oct-09 10:38 
GeneralRe: Sending a command to an IEnumerable method Pin
Lutosław24-Oct-09 1:01
Lutosław24-Oct-09 1:01 

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.