praveengb wrote:
Error 1 'Delegates.DelegateTest.RemoveSpaces(string)': not all code paths return a value
//reomve spaces
static string RemoveSpaces(string s)
{
string temp="";
int i;
Console.WriteLine("Removing spaces.");
for(i=0;i<s.Length;i++)
{
if (s[i] != ' ')
{
temp = temp + s[i];
return temp;
}
}
}
This method does not return anything if the if-case is never true. This leads to 'not every possible scenario' is returning a string as expected. Add a return statement after 'for' ends to correct it. If nothing else, return an empty string.
praveengb wrote:
Error 2 Cannot implicitly convert type 'int' to 'bool'
Your checking condition in for loop here:
for (j = 0; i = s.Length - 1; i--, j++) //Incorrect
It should be a boolean true-false condition. Try:
i <= s.Length -1
Sandeep Mewara [My last tip/trick]: Server side Delimiters in ASP.NET[^]