Click here to Skip to main content
15,896,557 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can I use local method in method Pin
Member 1115157117-Oct-14 22:43
Member 1115157117-Oct-14 22:43 
QuestionDeepCopy Not Working Pin
Kevin Marois17-Oct-14 8:28
professionalKevin Marois17-Oct-14 8:28 
AnswerRe: DeepCopy Not Working Pin
BillWoodruff17-Oct-14 8:42
professionalBillWoodruff17-Oct-14 8:42 
AnswerRe: DeepCopy Not Working Pin
Rob Philpott19-Oct-14 7:46
Rob Philpott19-Oct-14 7:46 
AnswerRe: DeepCopy Not Working Pin
Bernhard Hiller19-Oct-14 22:26
Bernhard Hiller19-Oct-14 22:26 
QuestionC# Socket Communication Pin
Lillepige17-Oct-14 8:17
Lillepige17-Oct-14 8:17 
AnswerRe: C# Socket Communication Pin
Richard Andrew x6417-Oct-14 9:49
professionalRichard Andrew x6417-Oct-14 9:49 
AnswerRe: C# Socket Communication Pin
Dave Kreskowiak17-Oct-14 9:52
mveDave Kreskowiak17-Oct-14 9:52 
AnswerRe: C# Socket Communication Pin
Eddy Vluggen17-Oct-14 10:49
professionalEddy Vluggen17-Oct-14 10:49 
AnswerRe: C# Socket Communication Pin
Cai Wallis-Jones18-Oct-14 1:40
Cai Wallis-Jones18-Oct-14 1:40 
GeneralC sharp file creation at specified time. Pin
kanswal7717-Oct-14 3:54
kanswal7717-Oct-14 3:54 
GeneralRe: C sharp file creation at specified time. Pin
BillWoodruff17-Oct-14 3:58
professionalBillWoodruff17-Oct-14 3:58 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7717-Oct-14 5:53
kanswal7717-Oct-14 5:53 
GeneralRe: C sharp file creation at specified time. Pin
BillWoodruff17-Oct-14 6:25
professionalBillWoodruff17-Oct-14 6:25 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7717-Oct-14 6:34
kanswal7717-Oct-14 6:34 
GeneralRe: C sharp file creation at specified time. Pin
BillWoodruff17-Oct-14 7:47
professionalBillWoodruff17-Oct-14 7:47 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7718-Oct-14 17:24
kanswal7718-Oct-14 17:24 
GeneralRe: C sharp file creation at specified time. Pin
Nicholas Marty17-Oct-14 4:32
professionalNicholas Marty17-Oct-14 4:32 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7718-Oct-14 17:38
kanswal7718-Oct-14 17:38 
GeneralRe: C sharp file creation at specified time. Pin
Dave Kreskowiak17-Oct-14 4:35
mveDave Kreskowiak17-Oct-14 4:35 
Question[c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046716-Oct-14 22:32
Member 1116046716-Oct-14 22:32 
AnswerRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 0:01
mveRichard MacCutchan17-Oct-14 0:01 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 0:15
Member 1116046717-Oct-14 0:15 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 2:12
mveRichard MacCutchan17-Oct-14 2:12 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 17:32
Member 1116046717-Oct-14 17:32 
Thank a lot for the reply! I think I have some grasp of it now, but am having some trouble visualising it. I asked a friend for some advice, according to him,

Quote:
the trick to getting it to work is dividing the square numbers in even rows by 6 and the remainder is the column number of that square number, then for the odd row's you just get the remainder of them but depending on what the remainder is, will determine what column they are, like if(squarenum % 6 == 0) then column is 5
and to find the row numbers you just use division by 6 aswell, like each 6 times you go through the loop go up(or down) a row


I think I understand what I have to do, just not really sure how. For example, how can I find the "even rows".

Funny thing is, I love puzzles like this, but this just has me completly stumped!

Again, thanks a lot for the replies guys.

EDIT:

OKAY! so I decided just to do it the long way, but I really want to know if there is a way to do it in less code. Here is my solution, any/all input would be very much appreciated!

C#
/// <summary>
       /// For a given square number, tells you the corresponding row and column numbers.
       /// Pre:  none.
       /// Post: returns the row and column numbers, via "out" parameters.
       /// </summary>
       /// <param name="squareNumber">The input square number.</param>
       /// <param name="rowNumber">The output row number.</param>
       /// <param name="columnNumber">The output column number.</param>
       private static void MapSquareNumToScreenRowAndColumn(int squareNumber, out int rowNumber, out int columnNumber){

           // ######################## Add more code to this method and replace the next two lines by something more sensible.  ###############################
           rowNumber = 0; // Use 0 to make the compiler happy for now.
           columnNumber = 0; // Use 0 to make the compiler happy for now.

           columnNumber = squareNumber % 6;
           rowNumber = squareNumber/6;

           //switch statement for assigning column values to odd rows
           int remainder = squareNumber%6;
           switch (remainder){
               case 0:
                   columnNumber = 5;
                   break;
               case 1:
                   columnNumber = 4;
                   break;
               case 2:
                   columnNumber = 3;
                   break;
               case 3:
                   columnNumber = 2;
                   break;
               case 4:
                   columnNumber = 1;
                   break;
               case 5:
                   columnNumber = 0;
                   break;

           }

           if (squareNumber >=0 && squareNumber <= 5){
               rowNumber = 6;
               columnNumber = squareNumber%6;

           }

           if (squareNumber >=6 && squareNumber <= 11){
               rowNumber = 5;
           }

           if (squareNumber >=12 && squareNumber <= 17){
               rowNumber = 4;
               columnNumber = squareNumber%6;
           }
           if (squareNumber >=18 && squareNumber <= 23){
               rowNumber = 3;

           }
           if (squareNumber >= 24 && squareNumber <= 29){
               rowNumber = 2;
               columnNumber = squareNumber%6;

           }
           if (squareNumber >= 30 && squareNumber <= 35){
               rowNumber = 1;

           }
           if (squareNumber >= 36 && squareNumber <= 41){
               rowNumber = 0;
               columnNumber = squareNumber % 6;
           }


       }//end MapSquareNumToScreenRowAndColumn


modified 18-Oct-14 0:55am.

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.