Skip to main content

Questions tagged [c#-7.2]

For issues relating to development with C#, version 7.2.

c#-7.2
0 votes
0 answers
29 views

How to add custom normalize image data by MlContext.Transform?

i'm using .NET framwork 4.7.2 and i'm deploying model AI to console app, i get stuck in preprocess data. i have flow preprocess data in python like this : img -= (104, 117, 123) (RGB image) I want to ...
Dũng Hoàng's user avatar
0 votes
2 answers
608 views

how to await until parallel task done

I'm new with C#. I'm writing window form for sorting files inside folder according to it extension. It's work when do the task with one folder but I modified it to do it from multiple item in listbox. ...
J. Sumittanun's user avatar
4 votes
1 answer
343 views

Overriding a method with a ref struct param in older C# versions

I'm trying to override a JsonConverter<T> in the System.Text.Json package which has an abstract Read method which can be ovveridden as: public override object Read(ref Utf8JsonReader reader, ...
arviman's user avatar
  • 5,205
4 votes
1 answer
385 views

If I have a c# readonly struct that has non readonly structs as members, will compiler create defensive copy with in parameter

so, if I have for example a struct PlayerData that has members of Vector3 structs defined in System.Numerics (not readonly structs) public readonly struct PlayerData { public readonly Vector3 ...
JohnE's user avatar
  • 41
2 votes
1 answer
691 views

Yield keyword can not be used in ref struct?

I would like to use yield in ref structure method: public ref struct RefStruct { public IEnumerator<int> GetEnumerator() { yield return 1; } } The compiler complains about ...
smolchanovsky's user avatar
6 votes
1 answer
1k views

What is the best practice to implement equality for readonly structs? [closed]

I've just started to program in C# last year and I'm still learning the language. I have a question regarding readonly struct type and equality comparison methods. When creating a struct in C#, I know ...
Ryo Asai's user avatar
  • 1,208
2 votes
1 answer
540 views

Are mutable structs copied when passed through methods via in parameters?

I want to minimize copying of structs in a maths library and read about the C# 7.2 in modifier, especially the warnings when using it with mutable structs. It so happens that I have this mutable ...
Ray's user avatar
  • 8,564
4 votes
0 answers
860 views

Is there a way to use the ReadOnlySpan<char> overloads for StringBuilder and TryParse methods in a netstandard2.0 class library?

I have a NetStandard2.0 class library. I have imported the System.Memory nuget package, which means I can use Span<T> inside it. That's well and good, but the nuget package doesn't seem to ...
rianjs's user avatar
  • 7,875
7 votes
3 answers
980 views

What is the difference between "this ref" and "ref this" when talking about C# 7.2 ref extension methods?

Consider the following extension methods: public static void Toggle(this ref bool @bool) => @bool = !@bool; public static void Toggle2(ref this bool @bool) => @bool = !@bool; These simply ...
taquion's user avatar
  • 2,727
4 votes
1 answer
581 views

C#. Ref returning delegate for ref extension method

I have the following extension method for monitoring a variable and awaiting until it has a given expected value: public static async Task AwaitForValue<T>(this Func<T> ...
taquion's user avatar
  • 2,727
6 votes
1 answer
591 views

Why is this method invocation ambiguous?

Why does the first call to Foo below compile but the second one results in an ambiguous invocation compiler error? (using c# 7.2) private static void AmbiguousAsyncOverload() { Foo(() =>...
eoinmullan's user avatar
  • 1,179
4 votes
2 answers
187 views

Using the is operator with unconstrained generics

C# Version: 7.2 My Ms Build version: Unknown (if anyone can tell me how to find it on my machine please do) My Version of Visual Studio: Visual Studio Professional 2019 I'm going to boil this down ...
Dave's user avatar
  • 2,928
3 votes
0 answers
562 views

Using readonly structs as Dictionary Key

I was wondering how readonly structs behave when used a key in a Dictionary. I'm aware the combition of readonly and 'in' is to prevent copies of large structs being made unnecessarily and that the ...
Dave's user avatar
  • 2,928
0 votes
1 answer
557 views

Compile C# 7.2 project from command line

I am creating test automation for my code generation library. I have a test project in C# 7.2. The project compiles with Visual Studio without any issues. My test is updating the code of this project....
polina-c's user avatar
  • 6,747
2 votes
1 answer
989 views

Is there a way to compare 2 ref structs by reference?

Recently I was wandering if it's possible to compare structs by reference. As reading a struct variable creates a copy of that variable, comparing standard structs by reference seems impossible. ...
Andrzej Gis's user avatar
  • 14.1k

15 30 50 per page
1
2 3 4 5 6