Questions tagged [backing-field]

36 questions
0
votes
1 answer

Backing field vs "value" keyword in property setter

I have a property with a backing field and some logic inside the setter. I wonder whether I should use the value keyword or the backing field. Option 1: private bool _backingField; public bool MyProperty { get => _backingField; set { …
Michael Haddad
  • 4,085
  • 7
  • 42
  • 82
0
votes
1 answer

Assign fields in constructor via Reflection Emit

Looking for resolution on how to assign properties w/ backing fields which I have created dynamically at RT in an instance constructor. The signatures match with compiler generated attributes as auto-properties. Essentially they would be…
Latency
  • 426
  • 3
  • 12
0
votes
1 answer

Fluent NHibernate: How do you change the underlying sql type for an automapped collection of strings?

I have a class: public class ParentClass { //other stuff IList ChildPages } When 'IList ChildPages' gets automapped by Fluent NHibernate a 'ChildPages' join table is created with a nvarchar(255) backing field for each…
Mark Rogers
  • 96,497
  • 18
  • 85
  • 138
0
votes
2 answers

Multiply Value in Set Backing Field in C#

I'm looking to multiply a value in the set backing field in C# (for an ASP.NET MVC application). I'm doing this to avoid issues with dividing floating point numbers and therefore the properties are integers that require to be multiplied and divided…
Gareth
  • 5,140
  • 5
  • 42
  • 73
0
votes
2 answers

VB.NET property declaration

I see we can define properties in two way in VB.NET. As below Private newPropertyValue As String Public Property ID() As String Get Return newPropertyValue End Get Set(ByVal value As String) …
user2739418
  • 1,623
  • 5
  • 29
  • 51
0
votes
0 answers

Why do I need to call the default constructor for `struct` with auto properties

This won't compile public struct Matrix { readonly double[] elems; public Matrix(int rows, int cols) { this.elems=new double[rows*cols]; this.Rows=rows; this.Columns=cols; } public int Rows { get;…
John Alexiou
  • 28,472
  • 11
  • 77
  • 133
1 2
3