dkim18
asked on
can't access class library functions?
Hi,
I have this vb.net application which I turned it into a class library.
I am trying to access this from the c# page.
I added the reference to it.
From my class, I added using my classlib name.
Then I tried to create an object but can't seem to create one.
Using Myclasslib;
Myclasslib.Mysubclass test = new Myclasslib.Mysubclass();
when I tried to use the method by test.Mymethod(), nothing shows up after test., any idea?
Thanks
I have this vb.net application which I turned it into a class library.
I am trying to access this from the c# page.
I added the reference to it.
From my class, I added using my classlib name.
Then I tried to create an object but can't seem to create one.
Using Myclasslib;
Myclasslib.Mysubclass test = new Myclasslib.Mysubclass();
when I tried to use the method by test.Mymethod(), nothing shows up after test., any idea?
Thanks
Is MyMethod defined as Public?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK.
When I create a function and instantiated it inside the function, it showed.
Can you guess why it would do that?
using Myclasslib;
public class Form1
{
private void Form1_Load(object sender, System.EventArgs e)
{
public Myclasslib.Mysubclass test = new Myclasslib.Mysubclass();
test.Mymethod();
}
}
When I create a function and instantiated it inside the function, it showed.
Can you guess why it would do that?
using Myclasslib;
public class Form1
{
private void Form1_Load(object sender, System.EventArgs e)
{
public Myclasslib.Mysubclass test = new Myclasslib.Mysubclass();
test.Mymethod();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For completeness, I suppose I should back pedal on what I mentioned previously. The statement, "just know that any method calls you perform must occur in some other method," is not entirely accurate. If you have a method that is marked as static, then you could call that method outside of a function. For example, the following method call is valid:
public class Form1
{
public static string test = GetString();
public static string GetString()
{
return "Hello World!";
}
}