Pass a string to a function

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
 
S

Shiva

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
 
L

Lukas Thanei

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top