I've recently downloaded VS2017 and have been trying out some of the new C#7 features. However, one is confusing me because it doesn't always work.
Local Functions...
Are these supposed to work in an MVC Web Application? I've created a brand new WPF Desktop application and it works, but when I create a brand new MVC Web Application, the following code doesn't work (yes, I know it's pointless).
public ActionResult Index()
{
void TestMethod(string message)
{
Console.WriteLine(message);
}
TestMethod("Why isn't this working?");
return View();
}
The IDE doesn't show an error, but when I compile it, it produces 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?