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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:06:48+00:00 2026-06-10T04:06:48+00:00

In C# one could write something like this: public static class Test { }

  • 0

In C# one could write something like this:

public static class Test
{
}
public class Test<T>
{
}

How can I do the same in C++/CLI?

I tried to define:

public ref class Test abstract sealed
{
};

generic<typename T>
public ref class Test
{
};

But I get a C2011 error: “‘class’ type redefinition.

I want to create a static class which defines convenient methods for creating instance of a generic class, just like System.Tuple.

Any help would be greatly appreciated!

  • 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-10T04:06:50+00:00Added an answer on June 10, 2026 at 4:06 am

    To be clear, you want to do this:

    generic<typename T>
    public ref class Test {};
    
    generic<typename T, typename U>
    public ref class Test {};
    

    You can’t do that in C++/CLI. It is a flaw, given that the CLR allows this. But it is one it inherited from C++. The C++/CLI language uses a lot of plumbing of the C++ compiler, inheriting its naming rules in the process. You can post to connect.microsoft.com but that will be closed quickly as “by design”.

    The only decent way forward is to move these generic types into a C# class library that you reference in your C++/CLI project. Or by settling for a compromise like renaming the rest of the classes, something like Test2 is palatable. Which does reflect the reality that these classes are entirely unrelated.

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

Sidebar

Related Questions

I'm working on an container class that looks something like this: class hexFile {
We have some code that looks like this: class Serializer { public: template<class Type>
Could some one give me pointers to tutorials that explains how to write a
When using the Scala interpreter, one could start it with an option like: C:\Users\John>scala
Simple case: I have an interface for logging messages, like this: public interface ILogger
I could easily write one, but I'm wondering if there is already a standard
How can I enforce that my test class covers a particular interface? Also is
I have the simplest PhoneGap app one could imagine! All I'm trying to do
In the Nav Services world one could specify kNavDontConfirmReplacement as an option to create
I was wondering if any one could help me out; I have a table

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.