Link to home
Start Free TrialLog in
Avatar of lmred
lmredFlag for United States of America

asked on

Referencing a method from another namespace

I must be missing something simple! Please help before I start banging  my head against my desk!!! I am referencing a method in a class from a different namespace. I cannot pick up my other method with the intellisense in the class that I am trying to call it fromHere is some sample code below:

using mytest2.x

namespace mytest
{
public class ServerOptions : System.Windows.Forms.Form
    {
          //***I can't this line below to appear in intellisense
           ExcelPreferences
    }
}

**************************************************
This code below is another .cs file:
**************************************************

using System;
using System.Collections.Generic;
using System.Text;

namespace mytest2.x
{
    class ExcelPreferences
    {
        const string constEnableViewDataInExcel = "EnableViewDataInExcel";
        const string constDefaultViewDataInExcel = "true";

        public ExcelPreferences()
        {

        }

        /// <summary>
        /// Gets or sets the boolean for the enable function.
        /// </summary>
        public static bool EnableViewDataInExcel
        {
            get
            {
                RegistryPreferences m_pPreferences = new RegistryPreferences();
                return (bool.Parse(m_pPreferences.GetPreference(constEnableViewDataInExcel, constDefaultViewDataInExcel)));
            }
            set
            {
                RegistryPreferences m_pPreferences = new RegistryPreferences();
                m_pPreferences.SetPreference(constEnableViewDataInExcel, value.ToString());
            }
        }
    }
}
ASKER CERTIFIED SOLUTION
Avatar of joechina
joechina

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of der_jth
der_jth

Actually, ExcelPreferences is internal (that is the default visibility for top-level classes). But yes, making it "public class ExcelPreferences" will do the trick, as will compiling both the files into a single assembly (csc /out:myprog.exe first.cs second.cs, or making them a single project in Visual Studio).
Avatar of lmred

ASKER

I don't believe this!!! I wasted hours on such a stupid mistake. I didn't even notice that because I thought the default was public. Thanks so much guys!!!

Lmred