I am new to c# with that in mind can some one please tell me how to call a class file that i have created in to a windows form file.for example how do i call a function that handles error logs to call and run on a form file. I hope u understand what i am trying to say.

Recommended Answers

All 3 Replies

If you have created the class in the same project you just instantiate it the same way you do other classes:

//if you created a class called MyClass with a method called DoStuff
//then you would call it like this:

MyClass class = new MyClass(); //create instance of class
class.DoStuff(); //call method of class
commented: very helpful +0

thanx i will try it out

Member Avatar for saravind84

Also make sure that the "windows form file Class" and the "MyClass" are in the same Namespace. Otherwise you need to qualify the class name with the Namespace. Suppose the namespace for the MyClass is NewNameSpace, then use the code below.(Modified the code posted above)

NewNameSpace.MyClass class = new NewNameSpace.MyClass(); //create instance of class
class.DoStuff(); //call method of class
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.