I am having a problem with my solution. I am trying to create an MVC application wherein the view has a textbox for a string, a dropdown list for sorting type(e.g bubble sort,quick sort) and a button to sort the string.
here is my code in controller:
[HttpPost]
public ActionResult total(string value1, String calci)
{
char[] total;
switch (calci)
{
case "bubbleSort":
total = value1.ToCharArray();
char temp;
for (int write = 0; write < total.Length; write++)
for (int sor = 0; sor < total.Length - 1; sor++)
if (total[sor] > total[sor + 1])
{
temp = total[sor + 1];
total[sor + 1] = total[sor];
total[sor] = temp;
}
return Content("Result " + total);
}
}
it keeps giving me an error of "not all code paths return a value" I really need to run this program, also ignore the "total" from my actionresult because my the original solution of this project is my calculator project.Thankyou!
break;at the end of your case. Also adefaultcase should be included.return.