Using C# 6's using static syntax in MVC App_Code display helpers

前端 未结 2 1337
遇见更好的自我
遇见更好的自我 2021-01-24 22:10

Is it possible to use C# 6.0\'s new \"using static\" notation inside of display helpers in App_Code in MVC 5?

I attempted to do so but it did not seem to like the syntax

2条回答
  •  滥情空心
    2021-01-24 22:30

    I think I'm using mvc 5 and it's working for me. System.Web.Mvc.dll version 5.2.3.0

    I'm running this in VS 2015 which uses c# 6.0. So it's either that or the version 5.2.3.0 that's doing it.

    So the answer by Kevin it may not be 100% correct.

    MVC 6 is not "stable" in a very broad sense of the word so we are using MVC5 atm.

    Note that at first it didn't find my static reference, but there was no squiggly. After cutting and repasting the "@using static" line a few times it started working. I can navigate to definition on my static extension method.

提交回复
热议问题