Possible Conflict with Class name & Property Name?

Posted by coffeeaddict on Stack Overflow See other posts from Stack Overflow or by coffeeaddict
Published on 2010-05-17T15:00:39Z Indexed on 2010/05/17 15:10 UTC
Read the original article Hit count: 201

If you have a namespace that contains a property in ClassA and a class that has the name of that Property somewhere else in your project and both are in the same namespace this won't cause conflicts will it?

So lets say I have a class named Car

namespace Dealer
{
   class Vehicle
   {
        // the main class that defines vehicle, so this is Dealer.Vehicle  (Vehicle.cs)
   }
}

and a property over in some other class

namespace Dealer
{
    class Dealer
    {
        public Vehicle Vehicle
        {
           get { return _vehicle; }
        }
    }
}

so for the second it is really this for the property

public Dealer.Vehicle Vehicle
{
     get { return _car; }
}

so now you have Dealer.Vehicle and Dealer.Dealer.Vehicle. Wondering of that would cause a conflict ever.

If both those classes are in the same namespace and

© Stack Overflow or respective owner

Related posts about c#

Related posts about namespaces