我知道.net core 3和.net standard 2.1开箱即用,但是我需要将字符的Span转换为本机类型(double,int等)。不幸的是,由于.net框架不支持.net标准2.1,因此我无法使用最新和最先进的软件。
是否有任何扩展方法可以帮助优化和转换.net std 2.0?
[int
确实提供了方法重载来解析Span<char>
和ReadOnlySpan<Char>
Span<char> mySpan = new char[] { '1', '2', '3', '4', '5', '6' };
var myInt = int.Parse(mySpan); //myInt = 123465
var parsedPassed = int.TryParse(mySpan,out var myInt2); //myInt = 123465
我正在使用netcoreapp2.2
,并且已启用LangVersion
7.2
,这是我的csproj的外观
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>7.2</LangVersion>
</PropertyGroup>