473,507 Members | 5,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return Statement in C#

Atran
319 Contributor
Hello, I still not understand return keyword in C#, do you can give me an easy example, thanks for your help.
May 29 '07 #1
1 892
Plater
7,872 Recognized Expert Expert
Hello, I still not understand return keyword in C#, do you can give me an easy example, thanks for your help.
The same as in C, C++, java (pretty much every language)

Expand|Select|Wrap|Line Numbers
  1. public string mystrfunc()
  2. {
  3.    string retval="";
  4.    return retval;
  5. }
  6.  
  7. public int myintfunc()
  8. {
  9.    int retval=0;
  10.    return retval;
  11. }
  12.  
  13. public bool myboolfunc()
  14. {
  15.    bool retval=false;
  16.    return retval;
  17. }
  18.  
  19. public void myvoidfunc()
  20. {
  21.    //do something
  22.    return;
  23. }
  24.  
  25.  
  26.  
May 29 '07 #2

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

Similar topics

30
2133
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
3
2770
by: Test | last post by:
Sorry, some people may have asked this question before. It is really hard to find relevant articles about this topic on the web using key words. I know it is not recommended to use return...
4
45160
by: bluedolphin | last post by:
This is my first function in Visual and I'm having a simple syntax syntax issue that I'm hoping someone can help correct for me. I have a function Public Function...
10
2588
by: LaEisem | last post by:
On-the-job, I have "inherited" a lot of old C language software. A question or two about when "casting" of null pointer constants is needed has occurred during behind-the-scenes cleanup of some...
3
2362
by: Marlene Stebbins | last post by:
My program has code like this: bigint bigSub(bigint minuend, bigint subtrahend) { bigint bigdiff; bigInit(&bigdiff); if(((cmp_ops(minuend.number, subtrahend.number))==1) && minuend.sign...
15
6705
by: Greenhorn | last post by:
Hi, when a function doesn't specify a return type ,value what value is returned. In the below programme, the function sample()is returning the value passed to 'k'. sample(int); main() { int...
6
2253
by: lovecreatesbeauty | last post by:
I ever missed a `return' statement when write a function `int HighDigit(Num)' to get the highest digit of an integer. But even if the `return' statement is ignored the function still can obtain...
15
2781
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
13
1850
by: jimjim | last post by:
Hello all, I ve come across the following code fragment and I was wondering why is the copy ctr called on return (rather than just returning the string statement obj. TIA string...
7
10289
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
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...
0
5619
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,...
1
5039
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...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
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 ...
0
411
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...

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.