How to alias a type with a using directive in my R

2019-04-05 13:39发布

问题:

I need to alias a type with a using directive, which is normally done like so:

using LocalResources = Resources.Admin.SomeResource;

How can I do this inside my Razor view so that I can then use it like @LocalResources.FirstName?

回答1:

Here is how

@using File = System.IO.File //at the top of the page then 
// use @File any where in the cshtml page.


回答2:

Razor does not currently support type or namespace aliasing. This is something that we might consider for future versions.