Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda