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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:36:28+00:00 2026-05-24T21:36:28+00:00

It is possible to serialize only a few properties of the class? ex: public

  • 0

It is possible to serialize only a few properties of the class?
ex:

public class Client
{
   [ProtoMember(1)]
   public int Id { get; set; } 

   [ProtoMember(2)]
   public string Name { get; set; }

   public int Age { get; set; } 

   [ProtoMember(3)]
   public string Guid { get; set; } 
}

Thus, I get the value of “Id” incorrect. The other properties are correct.
If I fill it with “[ProtoMember]” all the properties, the value of “id” is correct.
Why?


Actually the error is caused by other reasons you may be able to help me.

I convert String to Stream to perform tasks. In time to reverse this conversion I have error in the value of Id


var cli = new Client
{ Id = 222, Guid = "52369-fe5r6-74e2g-j1i4e", Age = 29, Name = "José"};

//Serialize
var ms = new MemoryStream();
Serializer.Serialize(ms, cli);
ms.Position = 0;
var reader = new StreamReader(ms);
var strStream = reader.ReadToEnd();

//Deserialize
var ms2 = new MemoryStream(Encoding.UTF8.GetBytes(strStream));


var obj = Serializer.Deserialize<Client>(ms2);

Thus, any value above 127, is converted to a different Int. Ex: 3104751

My conversion is wrong?

Obs: I’m sorry the poor English

  • 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-24T21:36:29+00:00Added an answer on May 24, 2026 at 9:36 pm

    It is. Just make sure to include the [ProtoContract] attribute for the class and use the exact same contract when serializing and deserializing.

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

Sidebar

Related Questions

I have a class public class Money { public string Currency { get; set;
Is it possible to serialize an object into a string or a byte array
Possible Duplicate: How to serialize an IList<T>? I wish to serialize an class (let's
Is it possible when using jQuery's $.serialize() or $.serializeArray() to get the types of
Is it possible via an attribute of some sort to serialize a string as
Possible Duplicate: In java how do I serialize a class that is not marked
I was wondering if this is possible. The serialize-string will be inserted in a
With a model such as .. class Base { public Child Child { get;
I know it is possible to serialize and unserialize in PHP and then have
Is it possible to specialize this template for any basic_string's? template<class T> struct X

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.