0

Ive got a class which i want to use within a c# windows application, It sounds really simple but where do i put the code which creates the class object and the code that uses the class? Ive tried it in most parts of the code but after creating the class object, VS either cant find the object or nothing besides the standard variable functions appear in the intellisense (.equals, .getHashcode etc).

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by ddanbe
0

create the object where you want to use it.
tell some more about class.
what actually you want to do with class?

you can put the code in any event or form load etc.

0

In the solutions explorer right click the project choose Add item... in the window that opens choose Class.
In there you can put all the code of your class.
Now suppose I made a Traingle class I could fill in the Piant event handler of the form with something like this:

private void Form1_Paint(object sender, PaintEventArgs e)
{
            Graphics G = e.Graphics;
            Triangle MyTriangle= new Triangle();
            MyTriangle.Side = 200;
            MyTriangle.Draw(G);
            . . .
}
0

Ok thanks, thats pretty much sorted it, the class was basically a console application i made which im now converting to a Windows application

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.