Easy Class Question

  • Thread starter Thread starter Keith Smith
  • Start date Start date
K

Keith Smith

I know I'm probably missing something simple here. I want to have a class
operate within some code like this. I do not want to make the class public
unless I have to. What am I doing wrong?

for (int y=0; y<3; y++)
{
MyStuff;
}
class MyStuff
{
MessageBox.Show("it worked");
}
 
This is more about general OOP (Object Oriented Progamming) than about
C# ...

It's impossible to give you even a short answer since it would involve
a lot of base issues.

So please, just look at the code below and try get some information
about OOP :-)

for (int y=0; y<3; y++)
{
MyClass anObjectOfMyClass = new MyClass();
anObjectOfMyClass.ShowAMessage();
}

class MyClass {
public void ShowAMessage()
{
MessageBox.Show("it worked");
}
}

What you wrote inside "MyStuff" is not a class definition, it's just
raw implementation.
A class have no implementation itself, but its methods have (or may
have).

Best Regards

Claudio Brotto
 
Back
Top