Struct initialization and default values – definitive assignment place #42331
Labels
doc-enhancement
Improve the current content [org][type][category]
dotnet-csharp/svc
in-pr
This issue will be closed (fixed) by an active pull request.
lang-reference/subsvc
Pri1
High priority, do before Pri2 and Pri3
Type of issue
Typo
Description
From https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct#struct-initialization-and-default-values
This phrase is little confusing. Having example
MSIL produced for .ctor body is
so field is initialized before access but in constructor body.
So, IMHO:
default
struct
, all fields are initialized bydefault
to0
-bit pattern viainitobj
.new
struct
, all fields are initialized as part ofctor
run where field and default initializations and are place to .ctor by compilation.Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct#struct-initialization-and-default-values
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/builtin-types/struct.md
Document Version Independent Id
0960802e-80c3-cb56-cb8b-ab1f1b20fb4e
Article author
@BillWagner
Metadata
The text was updated successfully, but these errors were encountered: