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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:42:34+00:00 2026-06-09T11:42:34+00:00

We have a framework built up whose API is this: T Deserialize<T>(string to deserialize)

  • 0

We have a framework built up whose API is this:

T Deserialize<T>(string to deserialize)
{
    //  XmlSerializer(typeof(T))
    //  deserialize and return
}

We’ve been passing it things like:

[XmlRoot("apple")]
public class Apple
{
    [XmlElement("Id")]
    public int AppleId { get; set; }
}

this works great when we are returned an apple, however, sometimes we are getting “notAnApple”. So I will either get “apple” or “notAnApple”. When I get “notAnApple”, I get an exception.

As we have a lot of code built around this method, I would prefer not to go around changing things like the method signature. I do, however, have full flexibility into passing whatever class I like into this deserialization method.

  • 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-09T11:42:36+00:00Added an answer on June 9, 2026 at 11:42 am

    Generally you “know” exactly what you’re serializing and deserializing. e.g. you may serialize like this:

    serializer.Serialize(stream, new Apple());
    serializer.Serialize(stream, new notAnApple());
    

    Then you’d serialize like:

    Apple apple = (Apple)deserialzer.Deserialize(stream);
    notAnApple peach = (notAnApple)desserializer.Deserialize(stream);
    

    You don’t normally randomly try to deserialize data to figure out what it is that you’re deserializing. Technically you already know because you have a specific file format or a specific stream format.

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

Sidebar

Related Questions

I have a custom built application framework written in PHP which I have been
I have built an API framework that includes a lot of communication-related options, including
This is my problem, I have a tiny PHP MVC framework i built. Now
I have built CMS on cakephp framework. I can delete just one or more
Does Play Framework 2.0 have any built-in equivalent to 1.2.x's jsAction ? If not,
I have a asp.net web site built with .net 2.0 framework. we recently purchased
My setup: Ubuntu LAMP, application built w/ zend framework My Problem: I have a
All, I have a PHP Web application built using Zend Framework and MVC with
I have a web application built in Asp.net framework 3.5 (.Net 2008), and I
So I have a framework we've built on codeigniter. It uses regular codeigniter sessions

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.