0

I would like to compile C# 7.0 solution in Visual Studio 2015, but I have syntax error:

Error

ErrorMessage : 'DateTime' is a type but is used like a variable.

This is related to 'out variables' changed in C# 7.0

Unfortunately I can not use VS2017 (community) and THIS TUTORIAL - not working (master branch is adapted to VS2017 now).

Do you have an idea how to solve this problem?

cs9112
  • 61
  • 2
  • 9
  • Unfortunately in this solution I have over 400 projects and can't add 'Microsoft.Net.Compilers' foreach project. – cs9112 Jul 26 '17 at 09:46
  • You've kinda painted yourself into a corner here. You want to compile code that uses C# 7.0 features, but you don't want to update to an IDE that supports C# 7.0, and you don't want to use the workaround to add C# 7.0 support to an older IDE. How many other options do you think there are? – BJ Myers Jul 27 '17 at 04:43

1 Answers1

0

You just need to declare a DateTime variable outside the call and pass the parameter with the out keyword like this:

DateTime yuorParam;
method( ..., ..., out yourParam);
Mauro Sampietro
  • 2,739
  • 1
  • 24
  • 50
  • 2
    This is nice workaroud but I would like to know, how to compile c# 7.0 solution with many projects. I can't refactor many projects to older way of declare 'out' variable. – cs9112 Jul 26 '17 at 11:00
  • You will find a working solution on this [answer](https://stackoverflow.com/questions/39461407/how-to-use-c7-with-visual-studio-2015) – Jaime Marín Jan 19 '19 at 19:24