Fix nullable
This commit is contained in:
@@ -5,10 +5,10 @@ namespace GerbilManagerWebAPI.Models
|
||||
public record Gerbil
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public Gender Gender { get; init; }
|
||||
public Litter? Litter { get; set; }
|
||||
public Breeder? Breeder { get; set; }
|
||||
public Guid Id { get; init; } // init => properties are immutable by default, they are only mutable in the constructor and initializer.
|
||||
public required string Name { get; set; } //required => parameter is necessary in constructor and object iniilization list. So it cannot be intantiated without it
|
||||
public required Gender Gender { get; set; }
|
||||
public Litter? Litter { get; set; } // Any variable where the ? isn't appended to the type name is a non-nullable reference type.
|
||||
public Breeder? Breeder { get; set; } // You use the null-forgiving operator ! following a variable name to force the null-state to be not-null. For example, if you know the name variable isn't null but the compiler issues a warning, you can write the following code to override the compiler's analysis:
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user