Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two identical object names; how to make VS ignore one of them?

I have basic User model class that I am using but the problem is that in ASP.NET MVC there is already some property named User that is getting HTTP authentication information.

Can I somehow make Visual Studio 2012 ignore the other one and use mine? It would be pretty unpractical to write Website.Models.Users.User every time I want to access it.

Here is a picture for you to understand my problem better. enter image description here

like image 331
Stan Avatar asked Dec 12 '25 08:12

Stan


1 Answers

You can alias your Namespace or Class, or Microsoft's Namespace or Class:

Replace:

using Website.Models.Users;

With:

using myUsers = Website.Models.Users;

or

using myUser = Website.Models.Users.User;

Then use it as: if(myUser. or if(myUsers.User. in your code

Alternatively, you could just rename your classes so there are no collisions.

like image 174
Tom Studee Avatar answered Dec 15 '25 04:12

Tom Studee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!