lmred
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 constDefaultViewDataInExce l = "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 .GetPrefer ence(const EnableView DataInExce l, constDefaultViewDataInExce l)));
}
set
{
RegistryPreferences m_pPreferences = new RegistryPreferences();
m_pPreferences.SetPreferen ce(constEn ableViewDa taInExcel, value.ToString());
}
}
}
}
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
const string constDefaultViewDataInExce
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
}
set
{
RegistryPreferences m_pPreferences = new RegistryPreferences();
m_pPreferences.SetPreferen
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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).
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
Lmred