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).

Recommended Answers

All 4 Replies

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.

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);
            . . .
}

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

It should not make any difference!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.