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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:47:00+00:00 2026-06-13T20:47:00+00:00

I am changing some public field to private by providing corresponding public property. for

  • 0

I am changing some public field to private by providing corresponding public property.

for example:

public string Name;

is change to

private string _name;
public string Name
{
    get{ return _name;}
    set{ _name = value;}
}

However, what about the [XmlAttribute] attribute on the original public field?
i.e. does

[XmlAttribute]
public string Name;

becomes:

[XmlAttribute]
private string _name;
public string Name
{
    get{ return _name;}
    set{ _name = value;}
}

or

private string _name;
[XmlAttribute]
public string Name
{
    get{ return _name;}
    set{ _name = value;}
}
  • 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-13T20:47:01+00:00Added an answer on June 13, 2026 at 8:47 pm

    second solution.

    By the way, you don’t need anymore (.net 3.0 and +) a private field, if you don’t do anything special in getter or setter.

    You can use auto-implemented properties.

    [XmlAttribute]
    public string Name {get;set;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object with a property implemented like public String Bla {get;set;} After
Say I have a class, User: public class User { private String name; private
Is it posible to re-cache app.config? for example after changing some fields in app.config
I have a class public class Money { public string Currency { get; set;
Which scenario should I use for changing private fields inside class methods/properties: public class
In the process of changing some code, I have spilt some functions into multiple
I'm changing some values of the record and set it to dirty afterwards. Although
I want to override the Tostring() method for changing some characters. Is it possible?
I'm having some trouble changing the colour and font on a TableView that I
I have some CheckBoxPreferences and I have no problem changing the icon for them

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.