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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:05:47+00:00 2026-05-16T05:05:47+00:00

I have the following situation below. This code will throw a compiler error for

  • 0

I have the following situation below. This code will throw a compiler error for Test2

The type ‘InheritedChild’ cannot be used as type parameter ‘T’ in the generic type or method ‘panelGenericIOGrid’. There is no implicit reference conversion from ‘InheritedChild’ to ‘SerializerBase’.

public class SerializerBase<T> 
{  
}
public class DirectChild    : SerializerBase<DirectChild> 
{ 
}
public class InheritedChild : DirectChild 
{ 
}

public  class panelGenericIOGrid<T> : UserControl
   where T: SerializerBase<T>, new()
{
}

...
panelGenericIOGrid<DirectChild> test;
panelGenericIOGrid<InheritedChild> test2;
...

I’m pretty convinced my implentation is funadmentally wrong. I want the following situation, both DirectChild and InheritedChild will give their appropriote type to the SerializerBase constuctor.

How do I get the code to work the way it needs to? Thanks!

Some info on the actual information. SerializerBase has a set of static functions that are implemented to automatically serialize and deserialize themselves based on their type.

DirectChild has a set of strings that are going to be stored on disk and recovered.

Inhertiedchild has all the members of DirectChild plus more.

Basically I’m going to need DirectChild.Serialize(filename), and IndirectChild.Serialize(filename), where the Serialize is a public member of SerializeBase

  • 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-16T05:05:47+00:00Added an answer on May 16, 2026 at 5:05 am

    It seems to me that you’re missing an interface:

    public interface ISerializerBase<T> { }
    public class SerializerBase<T> : ISerializerBase<T> { } 
    public class DirectChild : SerializerBase<DirectChild> { }
    public class InheritedChild : DirectChild, ISerializerBase<InheritedChild> { } 
    public class panelGenericIOGrid<T> where T: ISerializerBase<T>, new() { } 
    

    I don’t know how that will change your design though. It might be that you’ll need to reimplement some inherited methods or some interface methods in the InheritedChild.

    But, maybe you can do this otherwise:

    public interface MSerializable {}
    public static class Serializable {
      public static void Serialize(this MSerializable self, string fileName) { 
        // self will refer to the right type, 
        // no need to use generics if all you want is to serialize it ...
      }
    }
    
    public class DirectChild : MSerializable { }
    public class InheritedChild : DirectChild { } 
    public class panelGenericIOGrid<T> where T: MSerializable, new() { } 
    

    Will you do a binary serialization, or will you serialize it to XML?

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

Sidebar

Related Questions

I have faced some interesting situation. I have the following code to populate value
I have following situation - Have a MongoService class, which reads host, port, database
I have following situation. In a constructor of a pseudo class I attach a
I have following situation (simplified, of course): MyDomain.groovy: class MyDomain { MyAnotherDomain anotherDomain //
I have following situation, String a=<em>crawler</em> <em> Yeahhhhh </em></a></h3><table; System.out.println(a.indexOf(</em>)); It returns the 11
I have following situation: String a = A Web crawler is a computer program
I have following Situation, Server A sends some data (HTML form) to server B,
I have the following situation: vec1 <- c(A, B, D, C, E, A, C)
I have the following situation: function Mach3Code(Str: String): String; var StrOut: String; begin StrOut
I have the following situation. We want an reputation table to evaluate Users And

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.