denotes a class which is not valid in the current context

  • Thread starter Thread starter Guest
  • Start date Start date
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>");
 
Looks like you forgot to call the method. In you code you have just name of
class and not method.
Shimon.
 
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
 
Back
Top