denotes a class which is not valid in the current context

Discussion in 'ASP .Net' started by =?Utf-8?B?SmltIEhlYXZleQ==?=, Feb 21, 2005.

  1. 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>");
     
    =?Utf-8?B?SmltIEhlYXZleQ==?=, Feb 21, 2005
    #1
    1. Advertising

  2. in which method/event your calling listparamvalues methods?

    Cheers
    Vadivel Kumar


    "Jim Heavey" <> wrote in message
    news:...
    >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>");
     
    Vadivel Kumar, Feb 21, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?SmltIEhlYXZleQ==?=

    Shimon Sim Guest

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

    "Jim Heavey" <> wrote in message
    news:...
    >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>");
     
    Shimon Sim, Feb 21, 2005
    #3
  4. 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


    "Jim Heavey" <> wrote in message
    news:...
    > 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>");
     
    William F. Robertson, Jr., Feb 21, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Olurotimi Ige
    Replies:
    2
    Views:
    4,309
    Patrick Olurotimi Ige
    Feb 8, 2005
  2. Harry Haller
    Replies:
    4
    Views:
    6,024
    Laurent Bugnion [MVP]
    Feb 23, 2007
  3. asd
    Replies:
    1
    Views:
    445
    www.pulpjava.com
    Nov 9, 2006
  4. Ignacio Machin \( .NET/ C# MVP \)

    Error:denotes a 'field' where a 'class' was expected

    Ignacio Machin \( .NET/ C# MVP \), Mar 2, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    353
    Ignacio Machin \( .NET/ C# MVP \)
    Mar 2, 2007
  5. Thufir Hawat

    context.xml not parseable and valid

    Thufir Hawat, Feb 26, 2009, in forum: XML
    Replies:
    3
    Views:
    4,979
    stevedonato
    Jan 18, 2012
Loading...

Share This Page