C# 7 .NET / CLR / Visual Studio version requirements
C# 7 .NET / CLR / Visual Studio version requirements
You do NOT need to target .NET 4.6 and above, that is incorrect. To use Tuples, you need the System.ValueTuple NuGet package. Right on https://www.nuget.org/packages/System.ValueTuple/ you can see it says it supports 4.5 and above, and actually, it supports 4.0 and above. And if you want to get crazy, if you create your own System.ValueTuple class that does exactly what that package does, it will work back on .NET 3.5 and probably older too. For "Task-like" types, you also need a NuGet package, https://www.nuget.org/packages/System.Threading.Tasks.Extensions/. This package also works on .NET 4.5 and newer according to its documentation.
Other C# 7 features will just work on .NET 2 and above as they are just syntactic sugar. For example, I just wrote the following in .NET 2.0 and it correctly throws:
static void Main(string[] args)
{
string test = null;
string d = test ?? throw new ApplicationException("test");
}
Likewise, int.TryParse("123", out int i); works just fine in .NET 2.0.
I did not test every single C#7 feature, but in general, with the exception of Tuples (and their related features like deconstruction), it should work in .NET 2.0 and above as most of it is just syntactic sugar. That being said, yes you need VS2017 to compile C#7. I'm sure at some point other compilers will support C#7 but not today.
Features I confirmed work in .NET 2.0:
- Binary Literals
- Digit Separators
- Inline
outparameters - Using
_to discard out parameters - Local functions
- Type based pattern matching
if (obj is int i)andcase int i: - Constant pattern matching
if (i is 2) - Var pattern matching
if (i is var j) - Ref returns
- Throw expressions
- Expression bodied getters and setters
- Expression bodied constructors and finalizers
To use the full power of C# 7 out of the box (without referencing NuGet packages and so on) you need VS 2017 and .NET 4.7 as the Target Framework.
C# 7 .NET / CLR / Visual Studio version requirements的更多相关文章
- MySQL for Visual Studio Version
MySQL for Visual Studio Version Connector/Net Version Supported Visual Studio Version Supported MySQ ...
- Getting Visual Studio version of a Solution file
VS 6.0 -> 6.0 VS 2002 -> 7.0 VS 2003 -> 8.0 VS 2005 -> 9.0 VS 2008 -> 10.0 VS 2010 -& ...
- Visual Studio 2010初学者的调试指南:Mastering Debugging in Visual Studio 2010 - A Beginner's Guide
Introduction In the software development life cycle, testing and defect fixing take more time than a ...
- visual studio 2012 has stopped working
I had similar problem which was resolved by taking two steps : 1A. DELETE THE REGISTRY KEY : 32-bit ...
- Building Python 2.7.10 with Visual Studio 2010 or 2015 - Google Chrome
您的浏览器(Chrome 33) 需要更新.该浏览器有诸多安全漏洞,无法显示本网站的所有功能. 了解如何更新浏览器 × p-nand-q.com C++ Python Programming L ...
- 如何在Visual Studio VS中定义多项目模板
https://msdn.microsoft.com/en-us/library/ms185308.aspx Multi-project templates act as containers for ...
- CUDA 新版本 Visual Studio 和 CUDA 兼容性的小问题
▶ 升级到 Visual Studio 2017 和 CUDA 9.1 之后,直接编译以前的 CUDA C 程序出现了如下报错: 严重性 代码 说明 项目 文件 行 禁止显示状态 错误(活动) E00 ...
- How to check if Visual Studio 2005 SP1 is installed
How to check if Visual Studio 2005 SP1 is installed Check the following registry key. HKEY_LOCAL_MAC ...
- visual studio git 忽略文件配置模板
## Ignore Visual Studio temporary files, build results, and## files generated by popular Visual Stud ...
随机推荐
- canvas学习之初级运用
<html> <head> <meta charset=utf-8> <title>绘制简单图形</title> <style typ ...
- SEO要点
SEO要点:1.语义化html标签,用合适的标签嵌套合适的内容,不可过分依赖div,对浏览器更友善就能更容易被抓取.2.重要的内容html代码放在前面,放在左边.搜索引擎爬虫是从左往右,从上到下进行抓 ...
- 如何使用jMeter发送两个逻辑上相关的HTTP请求
在前一篇文章使用jMeter构造大量并发的随机HTTP请求里我通过jMeter构造了大量的HTTP GET并发请求,对服务器产生了大量读操作. 现在我有另一个需求场景:假设我开发了一个创建Servic ...
- 处理器拦截器(HandlerInterceptor)详解(转)
简介 SpringWebMVC的处理器拦截器,类似于Servlet开发中的过滤器Filter,用于处理器进行预处理和后处理. 应用场景 1.日志记录,可以记录请求信息的日志,以便进行信息监控.信息统计 ...
- debian设置limits.conf
最近已经把自己的游戏框架主要功能完成得差不多了,决定将自己的开发环境从debian7升级到debian9,不然太多第三方依赖都跟不上了.debian10刚出来,MongoDB还没适配,所以暂不考虑. ...
- oracle to_Char fm 函数
近期在使用oracle to_char函数处理浮点数时发现有坑,这里做个小结: 网上可以找到关于to_char中使用fm9990.0099中的相关解释: 0表示:如果参数(double或者float类 ...
- 微信小程序开发(十)获取手机的经纬度
// succ.wxml <view>经度:{{lon}}</view> <view>纬度:{{lat}}</view> // succ.js var ...
- 算法---FaceNet在Tf下的实战篇
FaceNet---Tensorflow下的下的实战篇 @WP20190225 ===============目录=============== 一.FaceNet算法简介 二.FaceNet配置与使 ...
- MySQL No Install zip安装方法
解压 解压安装包到一个目录,比如:D:\Database\mysql-5.1.55 配置 创建配置文件 创建一个my.ini文件,MYSQL目录下有几个my开头的ini文件,是针对不同配置使用,具体可 ...
- kvm批量创建虚拟主机
1.首先你的提前创建一个kvm虚拟机主机,才能批量复制创建 批量复制已经安装好的系统盘 `;.img centos7-$i.img && echo $i ;done 批量复制已经安装好 ...