EddieV
EddieV
CC#
Created by EddieV on 6/4/2023 in #help
❔ Non-nullable property must contain a non-null value when exiting constructor
I know what it says and what it wants my to do. However, my situation is: I have a bunch of objects (as properties) and that not all of them needs instantiating in a main class constructor. Given a condition, some will be and some won't be. In case of one that won't be, I still have no idea how to make the warning go away. Any suggestion? I'm sure how to Google this since using the warning would send me to a non-desirable direction.
12 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
The error said I haven't install .NET 6 SDK for arm64 even though I tried to install it TWICE. I can still run code and stuff, however the Intellisense or the Code Outline doesn't seem to work because they need OmniSharp. How do I fix this?
OmniSharp server started with .NET 6.0.402
.
Path: /.vscode/extensions/ms-dotnettools.csharp-1.25.7-darwin-arm64/.omnisharp/1.39.6-net6.0/OmniSharp.dll
PID: 83500

[STDERR] Unhandled exception.
[ERROR] A .NET 6 SDK for arm64 was not found. Please install the latest arm64 SDK from https://dotnet.microsoft.com/en-us/download/dotnet/6.0.
OmniSharp server started with .NET 6.0.402
.
Path: /.vscode/extensions/ms-dotnettools.csharp-1.25.7-darwin-arm64/.omnisharp/1.39.6-net6.0/OmniSharp.dll
PID: 83500

[STDERR] Unhandled exception.
[ERROR] A .NET 6 SDK for arm64 was not found. Please install the latest arm64 SDK from https://dotnet.microsoft.com/en-us/download/dotnet/6.0.
35 replies
CC#
Created by EddieV on 5/29/2023 in #help
❔ Using `with` to create a new record in return statement result in an error
private Point GetNewPosition(Commands command, Point position)
{
if (command == Commands.MoveNorth) return position with { Y++ };
if (command == Commands.MoveSouth) return position with { Y-- };
if (command == Commands.MoveEast) return position with { X++ };
if (command == Commands.MoveWest) return position with { X-- };
return null;
}
public record Point(int X, int Y);
private Point GetNewPosition(Commands command, Point position)
{
if (command == Commands.MoveNorth) return position with { Y++ };
if (command == Commands.MoveSouth) return position with { Y-- };
if (command == Commands.MoveEast) return position with { X++ };
if (command == Commands.MoveWest) return position with { X-- };
return null;
}
public record Point(int X, int Y);
I'm trying to make new records using with statement, but it resulted in an error saying The name 'Y' does not exist in the current context Can anybody help explain? Thanks
54 replies