denotes a class which is not valid in the current context

G

Guest

I create a class which would hold my static methods (methods I want to call
without having to instantiate the class). I then attempted to use it in
another class and I get the following error
"GenericDataBase.DataUtilities(cmd, "Stuff") denotes a class which is not
valid in the current context. What does this mean?

Here is the class that I created....

public class DataUtilities
{
public DataUtilities()
{
}
public static string ListParmValues(IDbCommand cmd, string breakCharacter)
{

StringBuilder vals= new StringBuilder();
......
return vals.ToString();
}
}

Here is the code in the "other" class that I am calling...

string val = GenericDatabaseBase.DataUtilities(cmd, "<br>");
 
V

Vadivel Kumar

in which method/event your calling listparamvalues methods?

Cheers
Vadivel Kumar
 
S

Shimon Sim

Looks like you forgot to call the method. In you code you have just name of
class and not method.
Shimon.
 
W

William F. Robertson, Jr.

This is assuming GenericDataBase is your namespace.

In your other class

GenericDatabaseBase.DataUtilities.ListParmValues(cmd, "<br>");

What the error means is you have a class named DataUtilities. You have
tried to call the class as a method. You need to include the actual method
name to get rid of this error.

Imagine if you have two static methods inside your class, how would it know
what method you are calling.

HTH,

bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top