Current project:
My Razor code:
@if(Session["Type"]?.ToString() == "Insurance") {
<text>policy of insurance</text>
} else if(Session["Type"]?.ToString() == "Warranty") {
<text>policy of warranty</text>
} else {
<text>protection policy</text>
}
Visual Studio explicitly flags this with an error,
Feature 'null propagating operator' is not available in C# 5. Please use language version 6 or greater.
And Visual Studio is explicitly using C# 6:
When I try to run the page itself, I get an error:
CS1525: Invalid expression term '.'
which shows that it is explicitly going after the period following the question mark.
This project was explicitly started as a C# 6 project, and I am quite confused as to why it is derping back to C#5.
Another strange issue: this is working just fine both in debug as well as on my local test setup (I publish to the filesystem, view using local IIS), but when I upload to the server (which has many, many other C#6 sites) it craps out. This is the first razor-side quirk I have ever run across that actually throws an error this badly.
So what's the difference? When we say electric shaver, we're referring to either a foil or rotary shaver, and when we say razor, we mean either a cartridge razor or a safety razor.
For the fastest and easiest shave, an electric razor will likely be the best bet, and some of our experts say that using one can also reduce the occurrence of ingrown hairs. “For those who don't like the traditional methods, I recommend foil shavers,” says Langevin.
Razor Basics Shaving is simply using a razor to remove the tip of the hair shaft that has grown up through the skin. Razors come in a bunch of different forms. There are standard razors that are either completely disposable or have a disposable blade that needs to be replaced regularly, and there are electric razors.
The benefits of safety razor shaveThat sharp blade is flush against your skin. So, be careful, but if you master the craft, you'll never look back. A single blade means less dragging across the face—and less chance that your top layer of skin will come off with the hairs.
I was having a similar problem and found that I was missing the following from my Web.config file:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With