473,545 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass a string to a function

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.cMa sk(string)': not all code paths return a value

Any idea?
Thanks
Ivan Sammut

Nov 16 '05 #1
3 1258
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) {
dowhateveryouwa ntornothing();
}
Lukas
Nov 16 '05 #2
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.

"Sammut" <sa*****@nextge n.net.mt> wrote in message
news:ud******** ******@TK2MSFTN GP12.phx.gbl...
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.cMa sk(string)': not all code paths return a value

Any idea?
Thanks
Ivan Sammut


Nov 16 '05 #3
Your method now accepts a string argument, and returns back a string as well.
If you don't want to return anything, change the method declaration to this:

private void cMask (string sText)

Check out this MSDN page for more info on methods
http://msdn.microsoft.com/library/de...pspec_10_5.asp

"Sammut" wrote:
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.cMa sk(string)': not all code paths return a value

Any idea?
Thanks
Ivan Sammut

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
30018
by: Woodster | last post by:
I have declared the following std::map<std::string, std::string> myMap; to pass myMap to functions should I be declaring functions as: void function(std::map<std::string, std::string>); or is there a preferred/better method of doing this?
110
9814
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object must be an object instead of
1
7657
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into the bottom of this email)
0
3307
by: Zlatko Matiæ | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems appear when someone is trying to use it as front-end for real server database systems such as PostgreSQL or MySQL. One of these problems is regarding...
9
1954
by: Alvin Bruney | last post by:
The more knowledgable I get about this .net world, the more questions I have. ..NET uses pass by reference for all objects....uhhh I mean pass by value. (Couldn't resist this jab) Consider a string object whose value is passed as a parameter to a function. The reference is pointing back to memory allocated on the heap where the contents...
4
2421
by: KC Eric | last post by:
Hi all, I have a dll file, it has a class, say: class Temp, this class has a function which has a delegate as a parameter, say: public void Test(GameOverHandler _overHandler)
2
7538
by: Steve Bottoms | last post by:
Is there any way to pass a login name/password when calling System.Web.Mail.SMTPMail? Can't find anything in the docs or KB... If not, any suggestions to get this functionality short of building something straight from sockets? Third party component isn't an option... :) Thanks! Jack
23
6509
by: Sanjay Kumar | last post by:
Folks, I am getting back into C++ after a long time and I have this simple question: How do pyou ass a STL container like say a vector or a map (to and from a function) ? function: vector<string> tokenize(string s){
5
7805
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into a WebService is that essentially we are passing an address of an object which resides on the 'local machine' i.e. a local machine object address....
2
4469
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as seperate process. If my windows application starts running,only if it completes fully, then my windows services should continue its execution. My...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.