Readonly Fields
See original GitHub issueI have been through the documentation but cannot find an example of how to do the following:
Given the class:
public class Plane
{
private readonly double length;
public double Length { get => length; }
public int Rows { get; set; }
public Plane(int rows, double Length)
{
Rows = rows;
length = Length;
}
public Plane(double Length)
{
length = Length;
}
}
var p = new Plane(4.33);
How do I serialize this as <Plane Length="4.33" /> ? I explicitly do not want the Rows to get serialized and the Length must be as an attribute.
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
readonly keyword - C# Reference
In a field declaration, readonly indicates that assignment to the field can only occur as part of the declaration or in a constructor...
Read more >What are the benefits to marking a field as `readonly` in C# ...
It's simply a check to ensure that once the object is fully constructed, that field cannot be pointed to a new value. However...
Read more >HTML input readonly Attribute
The readonly attribute is a boolean attribute. When present, it specifies that an input field is read-only. A read-only input field cannot be...
Read more >Readonly in C# - GeeksforGeeks
Readonly Fields : In C#, you are allowed to declare a field using readonly modifier. It indicates that the assignment to the fields...
Read more >Make fields readonly | ReSharper Documentation
Add the 'readonly' keyword to fields that only have read access · Press Ctrl Alt 0F or choose ReSharper | Edit | Cleanup...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks Mike!
Happy New Year. 😃 Closing this issue as the latest code addresses it to the best of our understanding. Please feel free to comment here and/or re-open a new issue if there is something not captured and needs to be addressed. Thank you!