Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:39:42+00:00 2026-06-02T22:39:42+00:00

When I implement an interface for the first time into a class I want

  • 0

When I implement an interface for the first time into a class I want either resharper 6 or visual studio 2010 to implement my properties as auto implemented properties and not put in the default value of throw new NonImplementedException();. How can I do this? For example:

public interface IEmployee
{
// want this to stay just like this when  implemented into class
ID { get; set; }
}

public class Employee : IEmployee
{
// I do not want the throw new NonImplemented exception
// I want it to just appear as an auto implemented property
// as I defined it in the interface
public int ID
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
}

Because this happens all the time, I am finding myself having to constantly refactor and manually remove those throw new UnImplimented() exceptions and manually make the properties be auto implemented… a pain! After all, I defined it as an auto implemented property in my interface.

Any help or advice much appreciated! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:39:43+00:00Added an answer on June 2, 2026 at 10:39 pm

    Note: your R# keyboard shortcuts may differ, I am using the Resharper 2.x keyboard schema.

    If you declare the interface on the class and then use Alt+Enter and select “Implement members”:

    Selecting “Implement mebers”

    Then you will get the default implementation, which happens to be throwing NotImplementedException, unless you change that.

    But if you ignore the suggested course of action and instead use Alt+Insert to open the Generate menu, you can select “Missing members”:

    Selecting “Missing members”

    This will open Generate window, where you can select to implement the property (or properties) as auto-implemented:

    Generate window

    That will do exactly what you want:

    class Employee : IEmployee
    {
        public int Id { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm constantly using the Implement interface shortcut in Visual Studio 2008. My problem is
I want to implement a derived class that should also implement an interface, that
I have a bunch of class who implement a common interface : Command. And
Sorry for the noobish question, this is the first time i try to implement
This is my first time using Protocols in Objective-C, and I'm running into a
I'm trying to implement the first example http://www.dotnetperls.com/convert-list-string into my method but I'm having
I am trying to implement some interface changes in my app, based on the
can we implement polymorphism using interface in c#? any example .
I'm trying to implement a REST interface under IIS5.1/ASP-classic (XP-Pro development box). So far,
I am currently trying to implement a marker interface in c#. But I haven't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.