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

  • Home
  • SEARCH
  • 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 728965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:44:32+00:00 2026-05-14T06:44:32+00:00

Using the release version of Visual Studio 2010 I think there’s a difference in

  • 0

Using the release version of Visual Studio 2010 I think there’s a difference in the “Implement Interface” expansion from VS2008

If I speicify an interface and implement it in a class as so:

public interface IRepository<T> where T : IModel
{
    T Get<T>(int id);
    void Update<T>(T item);
    int Add<T>(T item);
}    

public class MockRepository : IRepository<MockUser>
{
// ...
}

Then use the “Implement Interface” expansion and get this:

public class MockRepository : IRepository<MockUser>
{
    public T Get<T>(int id)
    {
        throw new NotImplementedException();
    }

    public void Update<T>(T item)
    {
        throw new NotImplementedException();
    }

    public int Add<T>(T item)
    {
        throw new NotImplementedException();
    }
}

Instead of what I expected

public class MockRepository : IRepository<MockUser>
{
    public MockUser Get<MockUser>(int id)
    {
        throw new NotImplementedException();
    }

    public void Update<MockUser>(MockUser item)
    {
        throw new NotImplementedException();
    }

    public int Add<MockUser>(MockUser item)
    {
        throw new NotImplementedException();
    }
}

The IDE uses the type variable name from the generic interface definition T instead of the specified concrete type MockUser.
Is this a bug? Or is something new just for VS2010 / .Net 4.0?

Update:
This is NOT a bug, I didn’t specify the interface as I inteded, it should be defined as:

public interface IRepository<T> where T : IModel
{
    T Get(int id);
    void Update(T item);
    int Add(T item);
}    

in other words I didn’t need to specify the Type parameter T at the interface and method level, but only at the interface.

  • 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-05-14T06:44:33+00:00Added an answer on May 14, 2026 at 6:44 am

    There’s no purpose to <T> as a type parameter to the interface’s methods. It’s not necessary, and if you remove it, you’ll get the expected behavior — except that the result is this:

    public class MockRepository : IRepository<IModel>
    {
        public IModel Get(int id)
        {
            throw new NotImplementedException();
        }
    
        public void Update()
        {
            throw new NotImplementedException();
        }
    
        public int Add(IModel item)
        {
            throw new NotImplementedException();
        }
    }
    

    Generic method type parameters are distinct from interface/class type parameters — I wouldn’t expect them to be implemented using IModel in your example. (In other words, the T in IRepository<T> is not the T in Get<T>.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Visual Studio 2010 Ultimate and I know there's the Qt VS Add-In.
I've build C++ program using Visual Studio 2008. Both release and debug version are
I recently installed Visual Studio 2010 (Ultimate edition, final version released in April), and
I'm currently using the Visual Studio Installer (Setup Project) in Visual Studio 2010 as
I'm using Visual Studio 2010 Beta 2 to learn to use Workflow Foundation (WF)
I am using Visual Studio 2010 Ultimate Edition and I've installed the Beta 2
I'm using Visual studio 2010 and I use a point gray camera. I use
I have deployed a website using Visual Studio 2010 on IIS6. I used one
In an OpenGL win32 program developed in Visual Studio C++ 2010, the debug version
I wrote an application that installs using the Visual Studio 2010 Setup Project. As

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.