473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Easy Class Question

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");
}
Nov 16 '05 #1
1 948
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

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Ahlers | last post by:
Obviously if you're looping or using a template, choosing output based on the current iteration is easy. For example, if you're walking a set of elements and you want index % 2 == 0 produce one...
6
by: Nick Dreyer | last post by:
In VB.NET I would like to not have to create property get/set procedures for every class variable I want to expose to Excel VBA projects in COM builds. Can anyone tell me if that is possible, or...
4
by: Wong chian | last post by:
Hi, I have this easy piece of code: public class Box1:System.web.ui.webcontrols.webcontrol { protected Button mybutton; protected override void OnInit() { InitializeComponent();
5
by: LedZep | last post by:
What up, All I need to do is enter a last name in a text box, query a MSAccess database and display the name with the corresponding columns. This is no problem, but when there are more than one...
7
by: Trev | last post by:
Hey, I just want to know (i know i should know this) how can i show up another form? I have 2 forms and the first one has a button on it that when i click the button i want the second form to...
1
by: melanieab | last post by:
Hi, If there's a textbox and the text entered is longer than what's visible (the textbox length), how do you make it so that the beginning chunk of text is visible (instead of the last part of...
7
by: Shadow Lynx | last post by:
I realize that his question has been asked, in many other forms, many times in this group. Even so, my tired eyes have not yet found a sufficient answer, so I've decided to "reask" it even though...
2
by: Tony Johansson | last post by:
Hello! I'm new to ASP.NET application but I have been using C# windows form for one year. I'm reading a book about Webbdevelopment. Below is a small ASP.NET application. I just wonder why is...
7
by: SteveM | last post by:
I am sure this is an easy question, but being relatively new to ASP.NET programming, I can not quite grasp what I need to accomplish what I need to do. What I have is a word document that is...
7
by: Mark Cooney | last post by:
Ok I have a class called Game which has an GameID value. I also have a routine that runs every 6 seconds. I need to see if the object Game exists with an GameID value = to the value of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.