Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written the following code:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

namespace ivycode.App_Classes
{
    
    Hashtable objHT = new Hashtable();
    database objDB = new database();
    string sRetVal = "";

    public class clsQuoteUs
    {

    }
}

Now the problem is despite of including System.Collections, I am not able to use Hashtable objHT = new Hashtable(); statement as it is not recognizing. I am working on a web application and in references i tried adding the .dll but it is not enlisted.

Please help resolve the problem.

Thanks

IB
Posted
Updated 28-Oct-13 1:03am
v2

1 solution

You can't put variables in a namespace, you need to put them in a class or method.

If you want to make these variables global accessible, put them in a static class GlobalVariables:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

namespace ivycode.App_Classes
{
    public static class GlobalVariables
    {
        public static Hashtable objHT = new Hashtable();
        public static database objDB = new database();
        public static string sRetVal = "";
    }
}

And to access them, use this code for example:
C#
GlobalVariables.sRetVal = "value";

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900