Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
returning a value from a method
Virgil Bevans
Jan 26 2016 9:01 PM
323
Reply
I am confused about my inability to return a value from a method. Both the calling method and the returning method are in the same form class definition. Following is a simplified example of my code.
public class frmMain:Form
{
public frmMain()
{
InitializeComponent();
}
private void getGreetingToolStripMenuItem_Click(object sender, EventArgs e)
{
string greeting = getGreeting()
// some further processing such as display greeting to console
}
private string getGreeting()
{
return "Hello"
}
}
When I run the form the variable "greeting" is null before and after execution of the method "getGreeting()". Near as I understand them, the dot Net help files indicate this should work; ditto for the examples I've found here and other help sites. What am I overlooking? Thanks.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Algorithm to count the number of stars in the night sky
interface