I read somewhere that having public properties is preferable to having public members in a class.
Is this only because of abstaraction and modularity? Are
Is this only because of abstaraction and modularity? Are there any other over-riding reasons?
Not that I know of; these reasons are by themselves compelling enough. But maybe someone else will jump in on this.
The property accesses are conerted into function calls by the compiler. For properties without a backup store (e.g. public string UserName { get; set; }), what would be the performance overhead compared to a direct member access? (I know it shouldn't usually make a difference but in some of my code, properties are accessed millions of times.)
In the resulting Intermediate Language, a property access is translated to a method call. However, as the word says, this is only an Intermediate Language: it gets compiled Just-In-Time down to something else. This translation step also involves optimizations like inlining of trivial methods, such as simple property accessors.
I would expect (but you'd need to test to make sure) that the JITter takes care of such accessors, so there should be no performance difference.