469,658 Members | 1,778 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

Calling class method from another class

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.

Nov 15 '05 #1
2 11104
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,PrevDa te,Highest);

"Jan" <ja*@noemail.net> wrote in message
news:3u********************@giganews.com...
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.


Nov 15 '05 #2
Jan <ja*@noemail.net> wrote:

<snip>
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Christian Dieterich | last post: by
7 posts views Thread by Klaus Friese | last post: by
7 posts views Thread by JJ | last post: by
5 posts views Thread by Nick Flandry | last post: by
8 posts views Thread by Mike C# | last post: by
7 posts views Thread by =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.