We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version Used: .net 5,C# 9.0 Steps to Reproduce:
[StructLayout(LayoutKind.Explicit, Pack = 1)] public struct UniUint32 { public UniUint32(uint _value) { value = _value; } public UniUint32(byte _b1,byte _b2,byte _b3,byte _b4) { b1=_b1; b2=_b2; b3=_b3; b4=_b4; } [FieldOffset(0)] public uint value; [FieldOffset(0)] public byte b1; [FieldOffset(1)] public byte b2; [FieldOffset(2)] public byte b3; [FieldOffset(3)] public byte b4; public static implicit operator uint(UniUint32 ip) => ip.value; public static unsafe implicit operator UniUint32(uint ip) => *((UniUint32*)&ip); }
Expected Behavior: Compiled successfully Actual Behavior:
Error CS0171 UniUint32.b4 D:\MySrc\DLBSvr\DLBSvr\Net\IPv4.cs 15 Active
The text was updated successfully, but these errors were encountered:
Duplicate of #7323 #10319 and dotnet/csharplang#1465
As mentioned in dotnet/csharplang#1465 (comment), if you're targeting .NET 5 You can use Unsafe.SkipInit.
Unsafe.SkipInit
If you're targeting older runtimes call the default this() constructor or use this = default (at the expense of a miniscule amount of runtime overhead.)
this()
this = default
Sorry, something went wrong.
thanks
No branches or pull requests
Version Used:
.net 5,C# 9.0
Steps to Reproduce:
Expected Behavior:
Compiled successfully
Actual Behavior:
Error CS0171 UniUint32.b4 D:\MySrc\DLBSvr\DLBSvr\Net\IPv4.cs 15 Active
The text was updated successfully, but these errors were encountered: