3

I have the following code:

public static class ItemsHelper
{
    public static object product
    {
        get
        {
            return HttpContext.Current.Items["product"];
        }
        set
        {
            HttpContext.Current.Items["product"] = value;
        }
    }
}

And then, in a function, I have the following expression:

if (ItemsHelper.product is null) return false;

I tested in visual studio 2017 and it works fine, but i tested in two different computers that runs visual studio 2015 and it retrieves the following error:

type expected )

Any one have an idea why this is happening?

Ricardo Rocha
  • 14,612
  • 20
  • 74
  • 130

1 Answers1

14

is null is a C# 7 feature. You would need a C# 7 compatible compiler to make your code compile.

Visual Studio 2017 ships with a compatible one but for Visual Studio 2015 you need to update. Check this question for instructions on how to update: How to use c#7 with Visual Studio 2015?.

henrikmerlander
  • 1,554
  • 13
  • 20