Reputation: 11469
I am trying to call a static function from a class but the intellisense is not picking it up?
the function return
public static ArrayList GetInfo(int infoID)
and i am calling from somewhere else in another class, I was trying to do something like
var myitem = myClassName.GetInfo(x);
but intelisense doesnt pick it up... as I type myClassName.
How can i call it? if at all possible
PS: I cant change the signature of the method :(.
Upvotes: 0
Views: 122
Reputation: 75123
normally you do have a namespace
as well, plus that static method has to be inside it's own class, for example, something like:
namespace MyHelpers {
public static class ArrayHelpers {
public static ArrayList GetInfo(int infoID) { ... }
}
}
now, no matter where you are in your application, and if that library is referenced to your current project you simply call it
ArrayList myitem = MyHelpers.ArrayHelpers.GetInfo(x);
remember that you need to give the full path and if your namespace is called namespace Model.Helpers { ...
then the full path will be:
ArrayList myitem = Model.Helpers.ArrayHelpers.GetInfo(x);
is you are using the using
declaration
using Model.Helpers;
you can use
ArrayList myitem = ArrayHelpers.GetInfo(x);
Upvotes: 1
Reputation: 243
Did you create the class in a subfolder of your project? If so, you need to call it like this:
subfolder.myclassname.getinfo()
Upvotes: 1
Reputation:
Static functions cant be accessed with variable name, but with class name. So basicly just call either just GetInfo(int)
( if you want to call it within the class where the GetInfo() is ) or YourClass.GetInfo(int)
( outside the class where GetInfo() is ).
If you are calling outside the class, make sure that you are using same namespace in both, or you are using appropriate using
statements.
Upvotes: 1