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;








0















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.











share|improve this question
























  • 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


















0















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.











share|improve this question
























  • 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














0












0








0








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.











share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 check Array.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






  • 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

















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













1 Answer
1






active

oldest

votes


















4














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)





share|improve this answer




















  • 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












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
);



);













draft saved

draft discarded


















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









4














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)





share|improve this answer




















  • 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
















4














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)





share|improve this answer




















  • 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














4












4








4







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)





share|improve this answer















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)






share|improve this answer














share|improve this answer



share|improve this answer








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













  • 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




















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현