i want to pass a class as parameter so it can be later used...i tryed making
function(object myClass)
but that didnt work..how do i do ? i want that in the end i make function(this);
Printable View
i want to pass a class as parameter so it can be later used...i tryed making
function(object myClass)
but that didnt work..how do i do ? i want that in the end i make function(this);
You can pass in 'this' if the object argument for the function accepts that type of object. Example (may not be 100 percent right, didn't get to test them):
You have a Form1 class and you are calling a function from it:
MyClass.Function(this)
class MyClass
{
public void Function(Form1 obj)
{
// Use your object.
}
}
OR
class MyClass
{
public void Function(System.Windows.Forms.Form obj)
{
// Cast obj into a Form1 variable
Form1 f = (Form1)obj;
// f now holds the pointer to the object you passed in.
}
}
it doesnt work...the class witch is callin is a bTab class..and it doesnt work neither as bTab sender or object sender...
You can pass it as an object but you will have to cast it to the appropriate type before accessing any of its members.
Code:((MyClass)o).Name // access member like this..