Results 1 to 2 of 2

Thread: [RESOLVED] static method problem

  1. #1

    Thread Starter
    Hyperactive Member r0k3t's Avatar
    Join Date
    Dec 2005
    Location
    Cleveland
    Posts
    361

    Resolved [RESOLVED] static method problem

    Hi there,

    I am doing an ASPX site with c# as the code behind. I haven't done this in a while but I needed to create a static class to check some variables - I stole this little bit of code of the net but I am having a problem.

    This is the class.

    Code:
    public static class QueryStringCheck
    {
    
    
        public static bool HasValue(object o)
        {
            if (o == null)
            {
                return false;
            }
    
            if (o == System.DBNull.Value)
            {
                return false;
            }
    
            if (o is String)
            {
                if (((String)o).Trim() == String.Empty)
                {
                    return false;
                }
            }
    
            return true;
        }
    
    }
    This is the code I am calling to make use of it...

    Code:
    if(!QueryStringCheck.Equals((object)Request.QueryString["TransactionId"]))
    {
              Response.Redirect("/MyAccount/PurchaseHistory.aspx");
    }

    But I get the error message
    Error 12 An object reference is required for the nonstatic field, method, or property 'object.Equals(object)'

    Now I remember going over this in school but it isn't like I can ever remember needing a static method (well having to create one myself - use ehm all the time)

    Can anyone point out what I am missing - I just re-read some material on the subject but it didn't seem to help? I don't see anything wrong.

    Thanks

  2. #2

    Thread Starter
    Hyperactive Member r0k3t's Avatar
    Join Date
    Dec 2005
    Location
    Cleveland
    Posts
    361

    Re: static method problem

    Two things -

    One, call the right method
    Two, the string doesn't need to be cast as an object...

    Duh for me!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width