c#-7.2

Where do I find the new Span<T>?

感情迁移 提交于 2019-11-29 13:23:44
Everyone is writing about how great the new type Span<T> is so I eagerly wanted to start rewriting a couple of methods in my libraries but where do I actually find it? I've updated Visual Studio 2017 to the latest version 15.5.0 where the change-log says: The C# compiler now supports the 7.2 set of language features including: Support for the Span<T> type being used throughout Kestrel and CoreFX via the ref struct modifier. but when I try to use it my code I'm getting an error and intellisense cannot resolve it. It's a .net 4.6.2 project and the language version is set to latest minor . Do I

Why would one ever use the “in” parameter modifier in C#?

白昼怎懂夜的黑 提交于 2019-11-28 05:13:26
So, I (think I) understand what the in parameter modifier does. But what it does appears to be quite redundant. Usually, I'd think that the only reason to use a ref would be to modify the calling variable, which is explicitly forbidden by in . So passing by in reference seems logically equivalent to passing by value. Is there some sort of performance advantage? It was my belief that on the back-end side of things, a ref parameter must at least copy the physical address of the variable, which should be the same size as any typical object reference. So, then is the advantage just in larger

What is the meaning of the planned “private protected” C# access modifier?

微笑、不失礼 提交于 2019-11-27 10:24:29
As part of the Roslyn documentation on GitHub, there's a page called Language feature implementation status , with planned language features for C# and VB. One feature I couldn't wrap my head around was private protected access modifier: private protected string GetId() { … } There is also a page of C# Language Design Notes , which explains many new features, but not this one. Eric Lippert said in a comment : Your error is in thinking of the modifiers as increasing restrictions. The modifiers in fact always decrease restrictions. Remember, things are "private" by default; only by adding

What is the use case for the (C# 7.2) “private protected” modifier?

浪尽此生 提交于 2019-11-27 00:32:57
问题 C# 7.2 introduces the private protected modifier. I've always protected access to fields with properties, allowing access via the Get/Set methods as I typically don't want the internal state of my object modified by anything other than my own class. I'm trying to understand why the C# language team have added this feature. After an extensive search on google, and reading and watching the 'what's new' media (I've watched the press release, details and video by Mads Torgerson), I am still none

Why would one ever use the “in” parameter modifier in C#?

自古美人都是妖i 提交于 2019-11-26 19:31:45
问题 So, I (think I) understand what the in parameter modifier does. But what it does appears to be quite redundant. Usually, I'd think that the only reason to use a ref would be to modify the calling variable, which is explicitly forbidden by in . So passing by in reference seems logically equivalent to passing by value. Is there some sort of performance advantage? It was my belief that on the back-end side of things, a ref parameter must at least copy the physical address of the variable, which

What is the meaning of the planned “private protected” C# access modifier?

 ̄綄美尐妖づ 提交于 2019-11-26 15:10:00
问题 As part of the Roslyn documentation on GitHub, there's a page called Language feature implementation status, with planned language features for C# and VB. One feature I couldn't wrap my head around was private protected access modifier: private protected string GetId() { … } There is also a page of C# Language Design Notes, which explains many new features, but not this one. Eric Lippert said in a comment: Your error is in thinking of the modifiers as increasing restrictions. The modifiers in