• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

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());
            }
        }
    }
}
0
lmred
Asked:
lmred
1 Solution
 
joechinaCommented:
your class ExcelPreferences is private.
Change it to public
0
 
der_jthCommented:
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).
0
 
lmredAuthor Commented:
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now