|
-
Jun 4th, 2008, 10:19 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Returning other type of values
Hi, i created a string that returns another string based on other string but what if that string thats based on is "" (nothing) i want to return a messagebox, how can i return a messagebox instead of a string ?
-
Jun 4th, 2008, 10:31 AM
#2
Fanatic Member
Re: Returning other type of values
I think this is a very bad idea... Is there any other way you can get around this? Perhaps before calling the method see if the string is "" and then return a messagebox?
C#.net, VB, C++, Java, VS 2005/2008
Dont' forget to rate posts that are helpful to you.
-
Jun 4th, 2008, 10:34 AM
#3
Thread Starter
Hyperactive Member
Re: Returning other type of values
like this ??
Code:
string str;
if (str.equals(""))
{
messagebox.show("Error")
}
?? yeah i could do that but theres no way to do it like i said ?
-
Jun 4th, 2008, 10:35 AM
#4
Fanatic Member
Re: Returning other type of values
Well the only problem with that is you need a return type for your method. Since you said it otherwise returns a string im assuming the current return type for the method is string, and if you just show a messagebox your method wont return anything...
C#.net, VB, C++, Java, VS 2005/2008
Dont' forget to rate posts that are helpful to you.
-
Jun 4th, 2008, 11:19 AM
#5
Re: Returning other type of values
But, if the current return type for the method is string, then either that string will contain something or it will contain nothing.
So, if I'm reading this correctly, it will do something if the string is not empty OR show a message box if it is, right?
-
Jun 4th, 2008, 11:22 AM
#6
Hyperactive Member
Re: Returning other type of values
You could always give the return type of the method as 'object' that way you can return a string or false (if the function is displaying a messagebox itself), for example.
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
-
Jun 4th, 2008, 01:16 PM
#7
Thread Starter
Hyperactive Member
Re: Returning other type of values
thanks..........i've solve my problem
-
Jun 4th, 2008, 01:25 PM
#8
Re: [RESOLVED] Returning other type of values
How did you solve your problem?
Post your resolution please, as it might help others with the same or similiar problem.
Thanks.
-
Jun 4th, 2008, 02:23 PM
#9
Thread Starter
Hyperactive Member
Re: [RESOLVED] Returning other type of values
i thought i resolved but im wrong.
-
Jun 4th, 2008, 02:25 PM
#10
Hyperactive Member
Re: [RESOLVED] Returning other type of values
 Originally Posted by Pac_741
i thought i resolved but im wrong.
Care to elaborate?
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
-
Jun 4th, 2008, 02:33 PM
#11
Thread Starter
Hyperactive Member
Re: [RESOLVED] Returning other type of values
i got it by myself!! wuuu!
okay here it is:
Code:
private string ToUpper(string Toupp)
{
string temp = null;
if (Toupp.Equals(""))
{
MessageBox.Show("Error");
}
else
{
temp = Toupp.Substring(0, 1);
return temp.ToUpper() + Toupp.Remove(0, 1);
}
return temp;
}
that the code do its it turn the first character of the ToUpp string.
-
Jun 4th, 2008, 02:35 PM
#12
Thread Starter
Hyperactive Member
Re: [RESOLVED] Returning other type of values
it turns it into a capitalized leter.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|