Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11601

Why does c# not let me simplify this namespace reference? [duplicate]

$
0
0

I have a project with a namespace and class defined like

namespace My.Company.Project.Models{   class Item   {...}}

and then in another project I try to use this class:

using My.Company.Project;...var obj = new Models.Item

but the compiler says that the "Using directive is unnecessary" and I get an error

CS0246 - The type or namespace name 'Models' could not be found (are you missing a using directive or an assembly reference?)

If my usage instead is

using My.Company;...var obj = new Project.Models.Item

it works fine. Why can I use My.Company but not My.Company.Project in my using statement and how can I qualify this so that I don't need such verbose namespace naming of classes?


Viewing all articles
Browse latest Browse all 11601

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>