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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:52:19+00:00 2026-05-15T09:52:19+00:00

In my solution, I have created public class to store value and already declare

  • 0

In my solution, I have created public class to store value and already declare [DataContract/DataMember] attribute.

For example,

[DataContract]
public class MeterSizeInfo
{
    string _meterSizeId;

    [DataMember(Order = 1)]
    public string MeterSizeId
    {
        get { return this._meterSizeId; }
        set { this._meterSizeId = value; }
    }

    string _meterSizeName;

    [DataMember(Order = 2)]
    public string MeterSizeName
    {
        get { return this._meterSizeName; }
        set { this._meterSizeName = value; }
    }

}

Then I need to add another public method exposing to entire project.
I wonder I have to add [DataMember(Order = 3)] for it or not.

    [DataMember(Order = 3)] //<--- must declare or not?
    public string DoSomething()
    {
        // do something...
    }

I understand that if I want to use serializer in protobuf-net to serialize my data stored in, I have to declare those attribute. but I’m not sure about that on method.

please help.
Thank you in advance.

  • 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-15T09:52:20+00:00Added an answer on May 15, 2026 at 9:52 am

    protobuf-net is a value serializer; it doesn’t know anything about methods, except for properties. If you use the same (or compatible) type, then the method will be present automatically, but this is nothing to do with protobuf-net (or any other serialization).

    Re the topic of adding attributes; with the current release it generally needs something to know which properties to serialize (and more importantly: with what identifiers). There is an implicit mode, but I don’t recommend it unless you know you aren’t going to be ever changing the type again. Ever. At all.

    In “v2”, you can remove the attributes; you have the option of using an external model for this, so you might have:

    var model = TypeModel.Create();
    model[typeof(MeterSizeInfo)].Add("MeterSizeId", "MeterSizeName");
    

    (don’t quote me on the exact API, but something like that)

    You can then use model.Serialize etc

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

Sidebar

Related Questions

I have created a new solution with a minimal amount of code that represents
I have a Pocket PC 2003 solution, consisting of three projects, that was created
I have seen Solutions created in Visual Studio 2008 cannot be opened in Visual
I am using NHibernate as my ORM solution and have a need for a
recently I was given the task to discover a C# solution I have never
I have a solution with several projects. One of them is a setup project.
I have a solution with many projects. One project contain few custom components. One
I have a solution consisting of five projects, each of which compile to separate
I have a solution with several projects, where the startup project has a post-build
I have a solution in Visual Studio 2005(professional Edition) which in turn has 8

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.