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
out
parameters - 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 ...
随机推荐
- Java学习路径(抛光砖)
这就是我刚刚在五孔问答中找到的Java学习路线图抛光砖价格.我个人认为,这条Java学习路线是可以的.它是2018年相对较新的Java学习路线,更符合企业就业标准. Java学习路径的第一阶段:Jav ...
- 三 HashSet
HashSet无序且不能重复 1.HashSet类的字段属性 //HashSet集合中的内容是通过 HashMap 数据结构来存储的 private transient HashMap<E,Ob ...
- ESP8266开发环境、编译、烧录
官方地址 中:http://www.espressif.com/zh-hans/support/download/overview?keys=&field_type_tid[]=14 英:ht ...
- vue.config.js基础配置
const path = require('path') const UglifyPlugin = require('uglifyjs-webpack-plugin') module.exports ...
- ThinkPHP模板继承和修改title
先说下模板继承: 假定:在View文件夹中 -> Public 公共模块 —>base/header/top/footer 4个html文件 这下面base文件使用include引入其他 ...
- vue-element-admin 之改变登录界面input的光标颜色
前话:用框架原有的login更改而不重写的话,恰好当你input背景设置成白色的时候,光标会找不到=>原因:原框架的光标颜色是#fff 操作更改光标颜色: 找到src/views/login/i ...
- shell脚本读取文件值并进行比较
#!/bin/bash keyValue=$(cat /dev/mcu/keyValue) //从文件中获取键值,注意:变量名和等号之间不能有空格 if [ $keyValue == 9 ] //注意 ...
- jedis五种数据类型的方法解释
常用命令 1)连接操作命令 quit:关闭连接(connection) auth:简单密码认证 help cmd: 查看cmd帮助,例如:help quit 2)持久化 save:将数据同步保存到磁盘 ...
- 扫描局域网ip存活
#!/bin/bash # #******************************************************************** #encoding -*-utf ...
- P5357 【模板】AC自动机(二次加强版)
思路 这题可以同时作为AC自动机和SAM的模板啊喂 AC自动机 对T建出AC自动机,把S在上面匹配,然后记录每个点被经过的次数,最后统计一次即可(暴力跳fail的复杂度是不对的) SAM 对S建出SA ...