A suggested resolution to the problem is missing. For example:
bool myBool = true;
if (myBool)
int myInt = 3;
CS1023 can be resolved by adding braces (there may be other solutions):
bool myBool = false;
if (myBool)
{
int myInt = 3;
}
Optionally, a link to some rational behind why C# is different to C/C++ in this case would be interesting/helpful. In Visual 2019 Pro, targeting C++ 17, the following both work in C++, but both generate CS1023 in C#:
// Works in C++
bool myBool = false;
if (myBool)
int myInt = 3;
// Also works in C++
bool myBool = false;
int i = 0;
if (myBool)
xx : i++;
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: 48795ddf-4f37-4701-d472-c685f8c8ca18
Version Independent ID: e37f6a77-3727-f165-c311-2a2d20fc58cb
[Enter feedback here]
Referring to this article: https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs1023
A suggested resolution to the problem is missing. For example: bool myBool = true; if (myBool) int myInt = 3;
CS1023 can be resolved by adding braces (there may be other solutions): bool myBool = false; if (myBool) { int myInt = 3; }
Optionally, a link to some rational behind why C# is different to C/C++ in this case would be interesting/helpful. In Visual 2019 Pro, targeting C++ 17, the following both work in C++, but both generate CS1023 in C#:
// Works in C++ bool myBool = false; if (myBool) int myInt = 3;
// Also works in C++ bool myBool = false; int i = 0; if (myBool) xx : i++;
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.