Calling class method from another class

  • Thread starter Thread starter Jan
  • Start date Start date
J

Jan

Here's the code with the problem:

class Startup
{
public static string Sym;
public static string PrevDate;
public static int [ ] Highest = new int[1800];

// ______________

public static void Begin ()
{
Sym = "ZQ";
PrevDate = "081803";
ReadMBC.ReadMB1(Sym,PrevDate,Highest);
}
}
}

The compiler says "The type or namespace name ReadMBC could not be found."
However, ReadMBC is a public class and ReadMB1 is a public static member
function of that class. It is not a namespace, and it compiles within the
same namespace as that of class Startup (shown above). The dot syntax shown
is correct for calling a member function of a class outside the class where
the call is made. What am I doing wrong?



Thanks.
 
When all else fails - always fully-qualify a method to make sure it's not a
namespace issue (not an obvious one, like not using a "using ..."
statement). So instead do:

mycompany.support.stuff.ReadMBC.ReadMB1(Sym,PrevDate,Highest);
 
The compiler says "The type or namespace name ReadMBC could not be found."
However, ReadMBC is a public class and ReadMB1 is a public static member
function of that class. It is not a namespace, and it compiles within the
same namespace as that of class Startup (shown above). The dot syntax shown
is correct for calling a member function of a class outside the class where
the call is made. What am I doing wrong?

Not posting the complete code so that we can test it for ourselves.
Please write a short but complete piece of code which fails to compile
but which you think should compile. It needn't actually do anything -
you should only need one empty method and one method to call it. If you
post that code, I'm sure we can find out why it's not compiling. You
may well find your problem while constructing the code though.
 
Back
Top