Skip to content

Help handling null decimal in data #2242

Answered by JoshClose
sgrassie asked this question in Q&A
Discussion options

You must be logged in to vote

NullValues are data that is converted to null. What you're doing would set null if the field was 0.

Your properties in Record aren't Nullable, so you don't want null anyway.

You can set a default of 0.

public record Data([Default(0)]decimal First, [Default(0)]decimal Second, [Default(0)]decimal Third);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sgrassie
Comment options

Answer selected by sgrassie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants