I recently downloaded VS2017 and tried some of the new C # 7 features. However, I am confused because this does not always work.
Local functions ...
Are they supposed to work in an MVC web application? I created a completely new WPF Desktop application and it works, but when I create a new MVC web application, the following code does not work (yes, I know, this is pointless).
public ActionResult Index() { void TestMethod(string message) { Console.WriteLine(message); } TestMethod("Why isn't this working?"); return View(); }
The error is not displayed in the IDE, but when I compile it, it gives a list of errors:
HomeController.cs(13,13,13,17): error CS1547: Keyword 'void' cannot be used in this context HomeController.cs(13,28,13,43): error CS1528: Expected; or = (cannot specify constructor arguments in declaration) HomeController.cs(13,28,13,29): error CS1003: Syntax error, '[' expected HomeController.cs(13,29,13,35): error CS1525: Invalid expression term 'string' HomeController.cs(13,36,13,43): error CS1026: ) expected HomeController.cs(13,36,13,43): error CS1003: Syntax error, ',' expected HomeController.cs(13,43,13,44): error CS1003: Syntax error, ']' expected HomeController.cs(13,43,13,44): error CS1002: ; expected HomeController.cs(13,43,13,44): error CS1513: } expected ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Am I doing something wrong?