How to 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
 
Sammut said:
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

private void cMask (string sText)
 
Well ... the error message tells you what the problem is. If you declare a
string function it must at some point return a string value. Your prototype
returns nothing. Either declare it as void, or put a return statement in
it, and the error goes away.

--Bob
 
Back
Top