auto-properties

c# constructors vs auto-properties and object initializers

I have used auto properties a lot but I have gone more and more away from that setting up classes with readonly backing fields initialized in the constructor. I remove all setters and only add the back if the property clearly need a setter. I find this makes my classes more robust and elegant OO wise and I am kicking myself for not doi...

What is the use case for Access.BackingField in Fluent NHibernate?

The documentation for Access.BackingField() indicates that this: Sets the access-strategy to use the backing-field of an auto-property. I understand that auto-properties get compiled with backing fields, but if the property is by definition a vanilla getter/setter, what advantage is garnered by going to the backing field directly v...

Unexpected C# behaviour with autoproperties and consturctors

It took me some debugging to figure this out (or so do I think). I will let the code loose on you and see what you come up with. There is a simple Contact class with: 1) some auto-properties, 2) a parameterized constructor which always increments the Contact.ID property and sets other properties according to the arguments it gets 3) ...

How to write a multi-line property in the auto-props section of the subversion config file?

What is the correct syntax? [auto-props] *.* = svn:ignore=bin obj or [auto-props] *.* = svn:ignore=bin;obj or none? Is it possible to write multi-line properties in the config file? ...

Problem with struct's constructor (compiler is yelling that I didn't fully initialize all the struct's auto-properties)

I have the following bit of code: public struct Interval { public double Min { get; set; } public double Max { get; set; } public Interval(double min = double.MinValue, double max = double.MaxValue) { Min = min; Max = max; } } The compiler is complaining that Backing field for automatically i...

Fluent NHibernate PropertyNotFoundException for Auto Property

I'm trying to get Fluent NHibernate to map a collection for me. My class definitions are as follows: public abstract class Team { public virtual Guid Id { get; set; } public virtual string Name { get; set; } } public class ClientTeam : Team { public virtual IEnumerable<Client> Clients { get; set; } } public class Client ...