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 573233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:42:08+00:00 2026-05-13T13:42:08+00:00

Here is my code public interface ITranslator<E, R> { E ToEntity<T>(R record); } class

  • 0

Here is my code

public interface ITranslator<E, R>
{       
    E ToEntity<T>(R record);
}

class Gens : ITranslator<string, int>
{
    #region ITranslator<string,int> Members

    public string ToEntity<MyOtherClass>(int record)
    {
        return record.ToString();
    }

    #endregion
}

When I compile this, I get an error Type parameter declaration must be an identifier not a type

Why is that I cannot have ToEntity<MyOtherClass> but can only have ToEntity<T> ??

Edit: what is MyOtherClass doing ? I am converting between entities(POCOs equivalent of Entity framework) and record(Object returned by the framework) for multiple tables/classes. So I would want to use this to do my class specific conversion

  • 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-13T13:42:09+00:00Added an answer on May 13, 2026 at 1:42 pm

    Your interface has a generic ToEntity<T> method that you’ve made non-generic in your implementation class Gens as ToEntity<MyOtherClass>. (A generic method could take any type parameter, possibly given certain constraints on T. Your Gens class is trying to provide a definition for ToEntity only for the type parameter MyOtherClass, which defeats the purpose of generics.)

    In your code example, it’s unclear how your Gens class is trying to use the MyOtherClass type; it’s certainly not involved in the logic of ToEntity. We’d need more information to be able to guide you further.

    To illustrate, here’s what your current definition of the ITranslator<E, R> interface offers, in plain English:

    “I provide a mechanism to translate
    any record of type R into an entity
    of type E, this mechanism being
    dependent upon any user-specified type
    T
    .”

    Your Gens class, on the other hand, the way it’s currently designed, “implements” the above interface like so:

    “I can translate integers to strings.
    I provide the illusion of allowing
    the user to specify a type to control
    how this translation is performed, but
    in fact there is no choice of type.
    The MyOtherClass class is involved
    somehow; that’s all I can say.”

    From these two descriptions, it’s clear that the Gens class is not really doing what the ITranslator<E, R> interface guarantees. Namely, it is not willing to accept a user-specified type for its ToEntity method. That’s why this code won’t compile for you.

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

Sidebar

Ask A Question

Stats

  • Questions 407k
  • Answers 407k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer the code requires an elevated privilege to access registry. However… May 15, 2026 at 6:33 am
  • Editorial Team
    Editorial Team added an answer qpid-tool looks like it will do what you want. There's… May 15, 2026 at 6:33 am
  • Editorial Team
    Editorial Team added an answer preg_replace needs delimiters $value = '20,000.00'; $value = preg_replace("/,/",'',$value); echo… May 15, 2026 at 6:33 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.