Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
Deconstructors and nullable reference types

I have a class with the deconstructor:

public void Deconstruct(out bool isSuccess, out TSuccess? value, out Error? error) {...}

Value of isSuccess defines whish of value or error is null.

Can I somehow let compiler know about this, so when I call:

var (isSuccess, value, error) = result;

analyzer knows which variable can and cannot be null?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

According to my knowledge you can't.

The NotNullWhenAttribute postcondition relies on the boolean return value. For example:

bool TryExecute(
    [NotNullWhen(true)] out TSuccess? value, 
    [NotNullWhen(false)] out Error? error)

Since deconstructor must be defined in the way that its return type is void, you can't mix the two techniques.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!