Pass a string to a function

  • Thread starter Thread starter Sammut
  • Start date Start date
S

Sammut

Hi,

I have the following function to which I need to pass a string variable

private string cMask (string sText)
{

}

but ever time I try to compile I get the error
'test.Form1.cMask(string)': not all code paths return a value

Any idea?
Thanks
Ivan Sammut
 
Hi,
Since you have specified this function would return a string, make sure it
does so before completion.
For this specific case, the function doesn't return anything.

Hi,

I have the following function to which I need to pass a string variable

private string cMask (string sText)
{

}

but ever time I try to compile I get the error
'test.Form1.cMask(string)': not all code paths return a value

Any idea?
Thanks
Ivan Sammut
 
Hi,

that error message means, that your function with return type "string" does
never return a value, so you have to return a string or use void as return
type for your function.

private string cMask (string sText) {
return "Hello World";
}

--- OR ---

private void cMask (string sText) {
dowhateveryouwantornothing();
}


Lukas
 
Back
Top