Stuck at searching and removing from arrayCreate ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?Deleting an element from an array in PHPHow to insert an item into an array at a specific index (JavaScript)?How do I empty an array in JavaScript?Loop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
Does a non-singular matrix have a large minor with disjoint rows and columns and full rank?
How could it be that 80% of townspeople were farmers during the Edo period in Japan?
Why are lawsuits between the President and Congress not automatically sent to the Supreme Court
What technology would Dwarves need to forge titanium?
Working hours and productivity expectations for game artists and programmers
Why were the bells ignored in S8E5?
Cannot remove door knob -- totally inaccessible!
Is Precocious Apprentice enough for Mystic Theurge?
Is there an academic word that means "to split hairs over"?
Five Powers of Fives Produce Unique Pandigital Number...Solve for X..Tell me Y
Do high-wing aircraft represent more difficult engineering challenges than low-wing aircraft?
Promotion comes with unexpected 24/7/365 on-call
Why does Taylor’s series “work”?
Using a Snow jacket for non snow conditions?
Canadian citizen who is presently in litigation with a US-based company
How can I safely determine the output voltage and current of a transformer?
Would a "ring language" be possible?
How to handle professionally if colleagues has referred his relative and asking to take easy while taking interview
Who is frowning in the sentence "Daisy looked at Tom frowning"?
Is it standard to have the first week's pay indefinitely withheld?
Why is the marginal distribution/marginal probability described as "marginal"?
How can I make dummy text (like lipsum) grey?
Would life always name the light from their sun "white"
Why does string strummed with finger sound different from the one strummed with pick?
Stuck at searching and removing from array
Create ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?Deleting an element from an array in PHPHow to insert an item into an array at a specific index (JavaScript)?How do I empty an array in JavaScript?Loop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Must add sales rep name, amount, calculate commission, and remove sales rep and sale from array.
I'm struggling with the searchSeller
method and have made no progress in over 24hrs.
static string SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount,
ref string salesRep)
int index = 0;
bool found = false;
while (!found && index < sellerCount)
if (salesRep = sellerNames[index])
found = true;
else
index++;
if (!found)
index = -1;
return sellerNames[index];
The issue seems to be somewhere in the line:
if (salesRep = sellerNames[index])
Error says:
cannot convert string to bool.
c# arrays methods
add a comment |
Must add sales rep name, amount, calculate commission, and remove sales rep and sale from array.
I'm struggling with the searchSeller
method and have made no progress in over 24hrs.
static string SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount,
ref string salesRep)
int index = 0;
bool found = false;
while (!found && index < sellerCount)
if (salesRep = sellerNames[index])
found = true;
else
index++;
if (!found)
index = -1;
return sellerNames[index];
The issue seems to be somewhere in the line:
if (salesRep = sellerNames[index])
Error says:
cannot convert string to bool.
c# arrays methods
Welcome to Stack Overflow. This is a great first question. :)
– aloisdg
Mar 23 at 16:51
1
Btw you should checkArray.FindIndex()
or maybe Linq's Enumerable.First(), Enumerable.Single() and Enumerable.Contains . Try it online
– aloisdg
Mar 23 at 17:09
add a comment |
Must add sales rep name, amount, calculate commission, and remove sales rep and sale from array.
I'm struggling with the searchSeller
method and have made no progress in over 24hrs.
static string SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount,
ref string salesRep)
int index = 0;
bool found = false;
while (!found && index < sellerCount)
if (salesRep = sellerNames[index])
found = true;
else
index++;
if (!found)
index = -1;
return sellerNames[index];
The issue seems to be somewhere in the line:
if (salesRep = sellerNames[index])
Error says:
cannot convert string to bool.
c# arrays methods
Must add sales rep name, amount, calculate commission, and remove sales rep and sale from array.
I'm struggling with the searchSeller
method and have made no progress in over 24hrs.
static string SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount,
ref string salesRep)
int index = 0;
bool found = false;
while (!found && index < sellerCount)
if (salesRep = sellerNames[index])
found = true;
else
index++;
if (!found)
index = -1;
return sellerNames[index];
The issue seems to be somewhere in the line:
if (salesRep = sellerNames[index])
Error says:
cannot convert string to bool.
c# arrays methods
c# arrays methods
edited Mar 23 at 16:49
Olivier Jacot-Descombes
71k1092144
71k1092144
asked Mar 23 at 16:36
electric.arcelectric.arc
112
112
Welcome to Stack Overflow. This is a great first question. :)
– aloisdg
Mar 23 at 16:51
1
Btw you should checkArray.FindIndex()
or maybe Linq's Enumerable.First(), Enumerable.Single() and Enumerable.Contains . Try it online
– aloisdg
Mar 23 at 17:09
add a comment |
Welcome to Stack Overflow. This is a great first question. :)
– aloisdg
Mar 23 at 16:51
1
Btw you should checkArray.FindIndex()
or maybe Linq's Enumerable.First(), Enumerable.Single() and Enumerable.Contains . Try it online
– aloisdg
Mar 23 at 17:09
Welcome to Stack Overflow. This is a great first question. :)
– aloisdg
Mar 23 at 16:51
Welcome to Stack Overflow. This is a great first question. :)
– aloisdg
Mar 23 at 16:51
1
1
Btw you should check
Array.FindIndex()
or maybe Linq's Enumerable.First(), Enumerable.Single() and Enumerable.Contains . Try it online– aloisdg
Mar 23 at 17:09
Btw you should check
Array.FindIndex()
or maybe Linq's Enumerable.First(), Enumerable.Single() and Enumerable.Contains . Try it online– aloisdg
Mar 23 at 17:09
add a comment |
1 Answer
1
active
oldest
votes
change
if (salesRep = sellerNames[index])
to
if (salesRep == sellerNames[index])
single =
will assign sellerNames[index]
to salesRep
while ==
is for comparison
And as you have already given the text to search, so returning same value does not have any point, I think you will want to return its index right?
return index; //indested of return sellerNames[index];
And you function should return int:
static int SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount, ref string salesRep)
1
wow. i have litterely been going crazy over this for over a day now! the simplest of things. Thank you kindly!!
– electric.arc
Mar 23 at 16:40
2
welcome to the programmers world
– Ashkan Mobayen Khiabani
Mar 23 at 16:42
@electric.arc: you can simplify your logic:int index = 0; while (index < sellerCount) if (salesRep == sellerNames[index]) return index; index++; return -1;
– Olivier Jacot-Descombes
Mar 23 at 16:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315965%2fstuck-at-searching-and-removing-from-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
change
if (salesRep = sellerNames[index])
to
if (salesRep == sellerNames[index])
single =
will assign sellerNames[index]
to salesRep
while ==
is for comparison
And as you have already given the text to search, so returning same value does not have any point, I think you will want to return its index right?
return index; //indested of return sellerNames[index];
And you function should return int:
static int SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount, ref string salesRep)
1
wow. i have litterely been going crazy over this for over a day now! the simplest of things. Thank you kindly!!
– electric.arc
Mar 23 at 16:40
2
welcome to the programmers world
– Ashkan Mobayen Khiabani
Mar 23 at 16:42
@electric.arc: you can simplify your logic:int index = 0; while (index < sellerCount) if (salesRep == sellerNames[index]) return index; index++; return -1;
– Olivier Jacot-Descombes
Mar 23 at 16:54
add a comment |
change
if (salesRep = sellerNames[index])
to
if (salesRep == sellerNames[index])
single =
will assign sellerNames[index]
to salesRep
while ==
is for comparison
And as you have already given the text to search, so returning same value does not have any point, I think you will want to return its index right?
return index; //indested of return sellerNames[index];
And you function should return int:
static int SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount, ref string salesRep)
1
wow. i have litterely been going crazy over this for over a day now! the simplest of things. Thank you kindly!!
– electric.arc
Mar 23 at 16:40
2
welcome to the programmers world
– Ashkan Mobayen Khiabani
Mar 23 at 16:42
@electric.arc: you can simplify your logic:int index = 0; while (index < sellerCount) if (salesRep == sellerNames[index]) return index; index++; return -1;
– Olivier Jacot-Descombes
Mar 23 at 16:54
add a comment |
change
if (salesRep = sellerNames[index])
to
if (salesRep == sellerNames[index])
single =
will assign sellerNames[index]
to salesRep
while ==
is for comparison
And as you have already given the text to search, so returning same value does not have any point, I think you will want to return its index right?
return index; //indested of return sellerNames[index];
And you function should return int:
static int SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount, ref string salesRep)
change
if (salesRep = sellerNames[index])
to
if (salesRep == sellerNames[index])
single =
will assign sellerNames[index]
to salesRep
while ==
is for comparison
And as you have already given the text to search, so returning same value does not have any point, I think you will want to return its index right?
return index; //indested of return sellerNames[index];
And you function should return int:
static int SearchSeller(int[] sellerSales, string[] sellerNames, int sellerCount, ref string salesRep)
edited Mar 23 at 16:42
answered Mar 23 at 16:39
Ashkan Mobayen KhiabaniAshkan Mobayen Khiabani
23.6k1868125
23.6k1868125
1
wow. i have litterely been going crazy over this for over a day now! the simplest of things. Thank you kindly!!
– electric.arc
Mar 23 at 16:40
2
welcome to the programmers world
– Ashkan Mobayen Khiabani
Mar 23 at 16:42
@electric.arc: you can simplify your logic:int index = 0; while (index < sellerCount) if (salesRep == sellerNames[index]) return index; index++; return -1;
– Olivier Jacot-Descombes
Mar 23 at 16:54
add a comment |
1
wow. i have litterely been going crazy over this for over a day now! the simplest of things. Thank you kindly!!
– electric.arc
Mar 23 at 16:40
2
welcome to the programmers world
– Ashkan Mobayen Khiabani
Mar 23 at 16:42
@electric.arc: you can simplify your logic:int index = 0; while (index < sellerCount) if (salesRep == sellerNames[index]) return index; index++; return -1;
– Olivier Jacot-Descombes
Mar 23 at 16:54
1
1
wow. i have litterely been going crazy over this for over a day now! the simplest of things. Thank you kindly!!
– electric.arc
Mar 23 at 16:40
wow. i have litterely been going crazy over this for over a day now! the simplest of things. Thank you kindly!!
– electric.arc
Mar 23 at 16:40
2
2
welcome to the programmers world
– Ashkan Mobayen Khiabani
Mar 23 at 16:42
welcome to the programmers world
– Ashkan Mobayen Khiabani
Mar 23 at 16:42
@electric.arc: you can simplify your logic:
int index = 0; while (index < sellerCount) if (salesRep == sellerNames[index]) return index; index++; return -1;
– Olivier Jacot-Descombes
Mar 23 at 16:54
@electric.arc: you can simplify your logic:
int index = 0; while (index < sellerCount) if (salesRep == sellerNames[index]) return index; index++; return -1;
– Olivier Jacot-Descombes
Mar 23 at 16:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315965%2fstuck-at-searching-and-removing-from-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to Stack Overflow. This is a great first question. :)
– aloisdg
Mar 23 at 16:51
1
Btw you should check
Array.FindIndex()
or maybe Linq's Enumerable.First(), Enumerable.Single() and Enumerable.Contains . Try it online– aloisdg
Mar 23 at 17:09