By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

multi methods

P: 26
is it possible that one class has multi methods and each method return a value ? because while I am trying to create a class with two methods each one return bool value I got the error

Error 24 'WiPosGUICSharp.sqldatabase.export(System.Collecti ons.Generic.List<string>)': not all code paths return a value D:\master\WIPos\graphic\GUI\WiPosGUICSharp\sqldata base.cs 103 23 WiPosGUICSharp
Feb 17 '09 #1
Share this Question
Share on Google+
1 Reply


tlhintoq
Expert 2.5K+
P: 3,525
Yes! Absolutly it is possible that a class has more than one method that returns a value. I would expect that description fits more classes than not.

A 'person' class might have a method for GetAge(), another for GetWeight() another for GetBirthday, etc.

As for your error of "not all paths return a value"... You've just missed someplace where the method is supposed to return a value/answer/calculation to the method that called it. For example: Maybe you only return a value inside an "if" construct, but not outside of it. If the "if" condition is never true then you never return a value. Or maybe inside the "try" block, but not inside the "catch" block, so once again there is a possible scenario where no value is returned.

Try placing a breakpoint at the beginning of the method and walking through it step by step.

If all else fails, post the method back in this thread and maybe a fresh set of eyes can see it.
Feb 17 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.