TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Virgil Bevans
NA
16
6.7k
returning a value from a method
Jan 26 2016 9:01 PM
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.
Reply
Answers (
2
)
Algorithm to count the number of stars in the night sky
interface