Difference between Automatic Properties and public field in C# 3.0

后端 未结 7 1172
忘掉有多难
忘掉有多难 2020-12-01 23:50

I failed to understand why auto implemented property language feature exist in C# 3.0.

What the difference it is making when you say

public string Fi         


        
7条回答
  •  鱼传尺愫
    2020-12-02 00:08

    The first is a public field, while the second is a public property.

    The main difference is in how they are used. For example WPF can only data bind to properties, not fields.

提交回复
热议问题