VivekDev
VivekDev

Reputation: 25399

Where are the using statements in Visual Studio

From all these years of exp, I feel weird. My Console App within Program class and Main method looks like this.

namespace NRules.Samples.RuleBuilder
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var repository = new CustomRuleRepository();
            repository.LoadRules();

            ISessionFactory factory = repository.Compile();
            ISession session = factory.CreateSession();
        }
    }
}

Thats the content of entire Program.cs file. The ISessionFactory and ISession live in NRules namespace and so I am expecting a using statement without which this should not compile. But strangely this complies and runs as well.

What am I missing? Is it that since the namespace here is NRules.Samples.RuleBuilder and so Visual Studio 2013 does not need NRules again? Also the tool tip correctly shows NRules.ISession when I hover over the interface line.

enter image description here

Upvotes: 0

Views: 192

Answers (1)

Joseph Nields
Joseph Nields

Reputation: 5661

Your namespace NRules.Samples.Rulebuilder is actually this:

namespace NRules
{
    namespace Samples
    {
        namespace Rulebuilder
        {
            internal class Program {/*...*/}
        }
    }
}

since your class is within the NRules namespace, you don't need a using statement to import public members of NRules.

Upvotes: 1

Related Questions