Click here to Skip to main content
15,920,111 members
Home / Discussions / C#
   

C#

 
AnswerRe: the code c# below that does not compile Pin
OriginalGriff13-Jun-18 6:19
mveOriginalGriff13-Jun-18 6:19 
GeneralRe: the code c# below that does not compile Pin
Member 1366398513-Jun-18 16:10
Member 1366398513-Jun-18 16:10 
GeneralRe: the code c# below that does not compile Pin
OriginalGriff13-Jun-18 21:32
mveOriginalGriff13-Jun-18 21:32 
AnswerRe: the code c# below that does not compile Pin
Gerry Schmitz13-Jun-18 7:48
mveGerry Schmitz13-Jun-18 7:48 
GeneralRe: the code c# below that does not compile Pin
Member 1366398513-Jun-18 16:16
Member 1366398513-Jun-18 16:16 
QuestionHow to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha11-Jun-18 22:13
Mohammad Abdullaha11-Jun-18 22:13 
AnswerRe: How to make an android phone does calls to people using vc#.net Pin
OriginalGriff11-Jun-18 23:03
mveOriginalGriff11-Jun-18 23:03 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha12-Jun-18 3:58
Mohammad Abdullaha12-Jun-18 3:58 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
OriginalGriff12-Jun-18 4:37
mveOriginalGriff12-Jun-18 4:37 
AnswerRe: How to make an android phone does calls to people using vc#.net Pin
Pete O'Hanlon11-Jun-18 23:14
mvePete O'Hanlon11-Jun-18 23:14 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha12-Jun-18 3:53
Mohammad Abdullaha12-Jun-18 3:53 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Richard MacCutchan12-Jun-18 9:05
mveRichard MacCutchan12-Jun-18 9:05 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Richard Andrew x6412-Jun-18 12:10
professionalRichard Andrew x6412-Jun-18 12:10 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Richard MacCutchan12-Jun-18 21:13
mveRichard MacCutchan12-Jun-18 21:13 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Pete O'Hanlon12-Jun-18 21:26
mvePete O'Hanlon12-Jun-18 21:26 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha13-Jun-18 5:29
Mohammad Abdullaha13-Jun-18 5:29 
AnswerRe: How to make an android phone does calls to people using vc#.net Pin
Gerry Schmitz13-Jun-18 7:42
mveGerry Schmitz13-Jun-18 7:42 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Mohammad Abdullaha13-Jun-18 9:48
Mohammad Abdullaha13-Jun-18 9:48 
GeneralRe: How to make an android phone does calls to people using vc#.net Pin
Gerry Schmitz13-Jun-18 9:58
mveGerry Schmitz13-Jun-18 9:58 
Questionfutronic fs80 fingerprint scanner integrat with c# Pin
Member 1020390311-Jun-18 21:52
Member 1020390311-Jun-18 21:52 
AnswerRe: futronic fs80 fingerprint scanner integrat with c# Pin
Richard MacCutchan11-Jun-18 23:13
mveRichard MacCutchan11-Jun-18 23:13 
QuestionArray bytes convert to json when export pdf through webservice Pin
Nishant.Chauhan8010-Jun-18 21:01
Nishant.Chauhan8010-Jun-18 21:01 
QuestionRe: Array bytes convert to json when export pdf through webservice Pin
Richard MacCutchan10-Jun-18 22:20
mveRichard MacCutchan10-Jun-18 22:20 
AnswerRe: Array bytes convert to json when export pdf through webservice Pin
Nathan Minier11-Jun-18 2:23
professionalNathan Minier11-Jun-18 2:23 
QuestionMultiple Loops Code Optimization Pin
Juanleroux10-Jun-18 16:31
Juanleroux10-Jun-18 16:31 
I have researched multiple sources and have come up with the following code that sorts the input array from low to high and outputs the sort order of position in the new sorted array.

The code below works, but I'd like to further optimize the final 11 x While loops into something that is more efficient. What is the best way to optimize this code?

Your help is greatly appreciated!

int[] i = {9, 2, 7, 6, 1, 3, 5, 4, 8};
   int[] j = (int[])i.Clone();
   
   int P01 = 0;
   int P02 = 0;
   int P03 = 0;
   int P04 = 0;
   int P05 = 0;
   int P06 = 0;
   int P07 = 0;
   int P08 = 0;
   int P09 = 0;
   
   int va = 0;
   int vp = 0;

   bool swapped = true;

   while (swapped) {

     swapped=false;
     va = 0;
	 
  //loop through all numbers in the array.
   while (va < i.Length -1)
   {
          //compare the two values.
           if (i[va] > i[va+1]) {

               int swap = i[va];
               i[va] = i[va+1];
               i[va+1] = swap;
               swapped=true;
           }

       //increment
       va++;  
   }
}

//loop through all numbers comparing original input array values vs. newly sorted array to determine position.
// Position 1
vp = 0;

while (vp < j.Length -1)
{
    if (j[0] = i[vp]) {
        P01 := vp + 1;
    }

       //increment
       vp++; 

}

// Position 2
vp = 0;

while (vp < j.Length -1)
{
    if (j[1] = i[vp]) {
        P02 := vp + 1;
    }

       //increment
       vp++; 

}

// Position 3
vp = 0;

while (vp < j.Length -1)
{
    if (j[2] = i[vp]) {
        P03 := vp + 1;
    }

       //increment
       vp++; 

}

// Position 4
vp = 0;

while (vp < j.Length -1)
{
    if (j[3] = i[vp]) {
        P04 := vp + 1;
    }

       //increment
       vp++; 

}

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.