tagged [automatic-properties]
Getter without body, Setter with
Getter without body, Setter with I have a property which is currently automatic. However, I now need it to perform some action every time it changes, so I want to add logic to the setter. So I want to...
- Modified
- 23 May at 13:25
Public Fields versus Automatic Properties
Public Fields versus Automatic Properties We're often told we should protect encapsulation by making getter and setter methods (properties in C#) for class fields, instead of exposing the fields to th...
- Modified
- 17 Dec at 23:57
Auto-properties with or without backing field - preference?
Auto-properties with or without backing field - preference? I know that when using auto-properties, the compiler creates its own backing field behind the screen. However, in many programs I read to le...
- Modified
- 10 Sep at 15:52
C# 6 auto-properties - read once or every time?
C# 6 auto-properties - read once or every time? I follow a pattern when setting certain properties whereby I check to see if the corresponding field is empty, returning the field if not and setting it...
- Modified
- 17 Aug at 13:43
Do you think "auto interface implementation" would be useful in .NET / C#
Do you think "auto interface implementation" would be useful in .NET / C# Consider this: And this: ``` public class StubPerson : IPerson { int ID { get { return 0; protected s
- Modified
- 8 Apr at 15:21
Resharper doesn't automatically convert to auto properties in Serializable classes - should I?
Resharper doesn't automatically convert to auto properties in Serializable classes - should I? I ran across this issue today and was able to determine that, when doing code cleanup, R# will not conver...
- Modified
- 12 Aug at 17:53
The case against automatic properties
The case against automatic properties > [C# 3.0 Auto-Properties - useful or not?](https://stackoverflow.com/questions/9304/c-3-0-auto-properties-useful-or-not) My boss and I regularly argue about th...
- Modified
- 23 May at 09:57
Use of properties vs backing-field inside owner class
Use of properties vs backing-field inside owner class I love auto-implemented properties in C# but lately there's been this elephant standing in my cubicle and I don't know what to do with him. If I u...
- Modified
- 16 Mar at 18:23
Auto-implemented properties with non null guard clause?
Auto-implemented properties with non null guard clause? I do agree with Mark Seeman's notion that [Automatic Properties are somewhat evil](http://blog.ploeh.dk/2011/05/26/CodeSmellAutomaticProperty.as...
- Modified
- 21 Jul at 17:31
How to properly define class properties?
How to properly define class properties? When defining a new class within a project what is the correct/best practice for doing so? In the past I have created classes such as: Normally I’d use a class...
- Modified
- 9 Jul at 19:21
C# 3.0 auto-properties — useful or not?
C# 3.0 auto-properties — useful or not? I am used to create my properties in C# using a private and a public field: Now, with [.NET](http://en.wikipedia.org/wiki/.NET_Framework) 3.0, we got auto-prope...
- Modified
- 24 Oct at 13:49
Automatic Properties and Structures Don't Mix?
Automatic Properties and Structures Don't Mix? Kicking around some small structures while answering [this post](https://stackoverflow.com/questions/414981/directly-modifying-listt-elements), I came ac...
- Modified
- 23 May at 11:59
Using a private auto property instead of a simple variable for a programming standard
Using a private auto property instead of a simple variable for a programming standard In a discussion with a peer, it was brought up that we should consider using auto properties for all class level v...
- Modified
- 11 Feb at 15:37
Why is it necessary to call :this() on a struct to use automatic properties in c#?
Why is it necessary to call :this() on a struct to use automatic properties in c#? If I define a struct in C# using automatic properties like this: ``` public struct Address { public Address(string ...
- Modified
- 23 Sep at 07:33
C# automatic property deserialization of JSON
C# automatic property deserialization of JSON I need to deserialize some JavaScript object represented in JSON to an appropriate C# class. Given the nice features of automatic properties, I would pref...
- Modified
- 23 May at 12:34
Encapsulate Collection in C#
Encapsulate Collection in C# Since 3.0 C# has great syntax sugar like auto-properties which a lot simplify implementation of encapsulation principle. This is good if you use it with atomic values, so ...
- Modified
- 16 Sep at 14:22
Adding Auto-Implemented Property to class using Roslyn
Adding Auto-Implemented Property to class using Roslyn I'm trying to learn Roslyn by building an existing but simple application from the ground up, which seems to be a productive way to learn this. A...
- Modified
- 12 Jul at 11:55