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 ...
随机推荐
- ZPL语言完成条形码的打印
近期因为项目的需求,需要使用到打印机来打印业务相关的条形码和其他信息,由于之前有操作其它打印机的经验,Leader就安排我来做这个了(凑哦,这能说我是懵逼的么).于是就开始了我的探索之旅啦,不对,是踩 ...
- 【Distributed】互联网安全架构
一.常见Web安全漏洞 1.1 XSS攻击 什么是XSS攻击手段 如何防御XSS攻击 1.2 SQL注入攻击 什么是SQL注入 SQL注入防攻击手段 MyBatis #与$区别 1.3 Http请求防 ...
- IntelliJ IDEA安装及破解
百度搜索IntelliJ IDEA,进入官网. 下载完成后进入安装界面 根据自己的情况选择安装路径 等待下载和安装完成. 安装完成 接下来我们运行IntelliJ IDEA 之后这里就要我们进行激活了 ...
- redis和memcacahe、mongoDB的区别
都是非关系型数据库,性能都非常高,但是mongoDB和memcache.redis是不同的两种类型.后两者主要用于数据的缓存,前者主要用在查询和储存大数据方面,是最接近数据库的文档型的非关系数据库. ...
- SQL Server 排序规则的影响
目录 SQL Server 排序规则 影响 效果演示 更改数据库排序规则 服务器级排序规则 数据库级排序规则 列级排序规则 查询时指定规则 建议 使用 Unicode 数据类型 使用二进制排序规则 [ ...
- PAT Basic 1084 外观数列 (20 分)
外观数列是指具有以下特点的整数序列: d, d1, d111, d113, d11231, d112213111, ... 它从不等于 1 的数字 d 开始,序列的第 n+1 项是对第 n 项的描述. ...
- ini文件读写 保存上次存储内容
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 自定义系统类加载器源码分析与forName方法底层剖析
基于上一次[https://www.cnblogs.com/webor2006/p/9240898.html]Launcher的分析继续,上次分析到了这: 接着创建应用类加载器,其创建过程其扩展类加载 ...
- java线程基础巩固---如何实现一个自己的显式锁Lock
拋出synchronized问题: 对于一个方法上了同锁如果被一个线程占有了,而假如该线程长时间工作,那其它线程不就只能傻傻的等着,而且是无限的等这线程工作完成了才能执行自己的任务,这里来演示一下这种 ...
- CentOS开放端口的方法
Centos升级到7之后,内置的防火墙已经从iptables变成了firewalld.所以,端口的开启还是要从两种情况来说明的,即iptables和firewalld.更多关于CentOs防火墙的最新 ...