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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:11:18+00:00 2026-06-05T23:11:18+00:00

Possible Duplicate: Interface defining a constructor signature? I have a mixed hierarchy of classes

  • 0

Possible Duplicate:
Interface defining a constructor signature?

I have a mixed hierarchy of classes and interfaces.

For using serialisation I need a default constructor present in
each class. I would really aprreciate if the compiler could tell
me that a default constructor is missing somewhere in the hierarchy.
(seeing the problem at compile time, not in the later tests)

What I would like to have could be some markup or attribute,
but I could not find anything.

Something like:

[ForceDefaultConstructor]
interface IVeryQuickSerializable
{   
    Serialize();
    Deserialize();
}

would be great!

But anything like that is very appreciated.

There is a limitation: I cannot change the Serialisation.
Making it generic would solve the problem, but I do not have
the source. Writing a wrapper might do the job, but it will
have a loophole for objects deriving from the toplevel Serialisation
interface (which may not be altered).

  • 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-05T23:11:20+00:00Added an answer on June 5, 2026 at 11:11 pm

    You can’t do that in an interface or attribute.

    Two thoughts:

    • integration test: use reflection to find all relevant classes, and check them in a test
    • expose your serialization code in a generic API that uses the T : new() clause, i.e.

      void Serialize<T>(T obj, ...) where T : IVeryQuickSerializable, new()
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Interface defining a constructor signature? I know that you cannot specify a
Possible Duplicate: Ternary Expression with Interfaces as a Base Class Classes: interface ISms {
Possible Duplicate: Why are interfaces preferred to abstract classes? Abstract class and Interface class?
Possible Duplicate: Interfaces: Why can't I seem to grasp them? I have seen many
Possible Duplicate: Is it safe for structs to implement interfaces? Take this code: interface
Possible Duplicate: Java Interfaces? What is the use of interface in java? Is interface
Possible Duplicate: Protected in Interfaces In Java why cant I have protected methods in
Possible Duplicate: Protected in Interfaces The following code snippet shows that an interface in
Possible Duplicate: Mongo interface I have been going through the GUI tools available for
Possible Duplicate: Why can't I have protected interface members? as title, in C#. Is

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.