-
July 22nd, 2015, 08:27 PM
#1
Need help
I made a class then I recall it but the codes doesn't display
-
July 23rd, 2015, 05:23 AM
#2
-
July 23rd, 2015, 09:44 AM
#3
Re: Need help
Originally Posted by Arjay
Your code is broken.
RezaBagherian2, you clearly need to provide more information, how about showing the code with which you have an issue?
-
July 23rd, 2015, 11:33 AM
#4
Re: Need help
the class in the program
public static class message
{
public message()
{
MessageBox.show("welcome to the world of programming");
}
}
and how recalled the class
var c1 = new message
c1.message();
every thing is OK the visual studio 2010 didn't show any kind of errors but when i run the program the message didn't show up
-
July 23rd, 2015, 02:12 PM
#5
Re: Need help
Make your message() static as well. You can't access a non-static method in a static class, even when instantiating it.
Last edited by DaddyWritesCode; July 23rd, 2015 at 02:14 PM.
-
July 23rd, 2015, 09:37 PM
#6
Re: Need help
Originally Posted by RezaBagherian2
the class in the program
public static class message
{
public message()
{
MessageBox.show("welcome to the world of programming");
}
}
and how recalled the class
var c1 = new message
c1.message();
every thing is OK the visual studio 2010 didn't show any kind of errors but when i run the program the message didn't show up
The code you posted doesn't compile. You need to get the code to compile before it will run.
-
July 23rd, 2015, 09:42 PM
#7
Re: Need help
Originally Posted by DaddyWritesCode
Make your message() static as well. You can't access a non-static method in a static class, even when instantiating it.
Unfortunately that isn't a method (as methods need to return either void or a value). It's more like a constructor, but you can't have a non static constructor inside a static class.
Tags for this Thread
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
|