名称 'u8' 在 ASP.NET 核心 Microsoft.Net.Http.Headers 的当前上下文中不存在
The name 'u8' does not exist in the current context in ASP.NET Core Microsoft.Net.Http.Headers
我尝试为 Microsoft.Net.Http.Headers
构建 ASP.NET 核心源代码,但由于下面的某些代码而出现很多错误。请问我该如何解决?我使用的 IDE 是 Visual Studio 2022 社区。语言版本显示预览。
private static ReadOnlySpan<byte> MimePrefix => "\"=?utf-8?B?"u8;
看了Encoded-word Syntax
,还是不知道你想要什么,所以请告诉我你需要什么样的字符串,我会进一步帮助你。
可以先参考下面的代码:
private static string MimePrefix => "\"=?utf-8?B?\"u8"; // '=?utf-8?B?'u8
private static ReadOnlySpan<byte> MimePrefix1 => Encoding.ASCII.GetBytes("=?utf-8?B?");
这是 C# 11 的新特性 - Utf8 Strings Literals:
string s1 = "hello"u8; // Error
var s2 = "hello"u8; // Okay and type is byte[]
Span<byte> s3 = "hello"u8; // Okay due to an implicit user-defined conversion from byte[] declared on Span<byte>.
ReadOnlySpan<byte> s3 = "hello"u8; // Okay due to an implicit user-defined conversion from byte[] declared on ReadOnlySpan<byte>.
特征是 merged 到 Visual Studio 17.3p1.
就像commit's作者的谈话:
Also, folks likely need to update VS for the feature to light up.
我尝试为 Microsoft.Net.Http.Headers
构建 ASP.NET 核心源代码,但由于下面的某些代码而出现很多错误。请问我该如何解决?我使用的 IDE 是 Visual Studio 2022 社区。语言版本显示预览。
private static ReadOnlySpan<byte> MimePrefix => "\"=?utf-8?B?"u8;
看了Encoded-word Syntax
,还是不知道你想要什么,所以请告诉我你需要什么样的字符串,我会进一步帮助你。
可以先参考下面的代码:
private static string MimePrefix => "\"=?utf-8?B?\"u8"; // '=?utf-8?B?'u8
private static ReadOnlySpan<byte> MimePrefix1 => Encoding.ASCII.GetBytes("=?utf-8?B?");
这是 C# 11 的新特性 - Utf8 Strings Literals:
string s1 = "hello"u8; // Error
var s2 = "hello"u8; // Okay and type is byte[]
Span<byte> s3 = "hello"u8; // Okay due to an implicit user-defined conversion from byte[] declared on Span<byte>.
ReadOnlySpan<byte> s3 = "hello"u8; // Okay due to an implicit user-defined conversion from byte[] declared on ReadOnlySpan<byte>.
特征是 merged 到 Visual Studio 17.3p1.
就像commit's作者的谈话:
Also, folks likely need to update VS for the feature to light up.