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

254
Views
How to disable the NotImplementedException for the auto-implemented property?

I'm having trouble with C# auto implementing the 'NotImplementedException' to the auto-implemented properties whenever I generated them.

This is the interface class :

public interface IPerson
{
    string Name {get;set;}
    int Age {get; set;}
    char Gender {get; set;}
    string Email {get;set;}
    string Address {get;set;}
}

This is the derived class. It's auto-implementing 'NotImplementedException' method whenever I tried to implement the interface to the derived class.

public class Student : IPerson
{
    public Student()
    {

    }

    public string Name { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
    public int Age { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
    public char Gender { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
    public string Email { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
    public string Address { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}

Is there a way to make that the accessor methods in Student class is not auto-implemented with 'NotImplementedException' when I implement and generated the members from the IPerson interface ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Selecting prefer auto properties will implement properties in interfaces with just get or set instead of throwing NotImplementedExceptions

This is what the setting looks like in VS 2022

enter image description here

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!