Quantcast
Channel: Difference between Property and Field in C# 3.0+ - Stack Overflow
Browsing latest articles
Browse All 11 View Live

Answer by maytham-ɯɐɥʇʎɐɯ for Difference between Property and Field in C# 3.0+

Among other answers and examples, I think this example is useful in some situations. For example let say you have a OnChangeproperty like following:public Action OnChange { get; set; }If you want to...

View Article



Answer by user1849310 for Difference between Property and Field in C# 3.0+

You should always use properties instead of fields for any public fields.This ensures that your libraryhas the ability to implement encapsulation for any field if required in future without breaking...

View Article

Answer by BradleyDotNET for Difference between Property and Field in C# 3.0+

There is one other important difference between fields and properties.When using WPF, you can only bind to public properties. Binding to a public field will not work. This is true even when not...

View Article

Answer by Zoran Horvat for Difference between Property and Field in C# 3.0+

Accessors are more than fields. Others have already pointed out several important differences, and I'm going to add one more.Properties take part in interface classes. For example:interface IPerson{...

View Article

Answer by Brian Rasmussen for Difference between Property and Field in C# 3.0+

Fields and properties look the same, but they are not. Properties are methods and as such there are certain things that are not supported for properties, and some things that may happen with properties...

View Article


Answer by Erik Funkenbusch for Difference between Property and Field in C# 3.0+

Properties and Fields may, in many cases, seem similar, but they are not. There are limitations to properties that do not exist for fields, and vice versa.As others have mentioned. You can make a...

View Article

Answer by AnthonyWJones for Difference between Property and Field in C# 3.0+

The fundamental difference is that a field is a position in memory where data of the specified type is stored. A property represents one or two units of code that are executed to retrieve or set a...

View Article

Answer by Dustin Campbell for Difference between Property and Field in C# 3.0+

A couple quick, obvious differencesA property can have accessor keywords.public string MyString { get; private set; }A property can be overridden in descendents.public virtual string MyString { get;...

View Article


Answer by Frederik Gheysels for Difference between Property and Field in C# 3.0+

The first one:public string MyString {get; set; }is a property; the second one ( public string MyString ) denotes a field.The difference is, that certain techniques (ASP.NET databinding for instances),...

View Article


Answer by Mark Ingram for Difference between Property and Field in C# 3.0+

Encapsulation.In the second instance you've just defined a variable, in the first, there is a getter / setter around the variable. So if you decide you want to validate the variable at a later date -...

View Article

Difference between Property and Field in C# 3.0+

I realize that it seems to be a duplicate of What is the difference between a Field and a Property in C#? but my question has a slight difference (from my point of view):Once I know thatI will not use...

View Article
Browsing latest articles
Browse All 11 View Live




Latest Images