在java中我們對屬性設置值或者獲取值是通過set和個頭方法的,在C#中有點不同,在java中用習慣了,所以有點不適應。看代碼

public class studyingClass
    {
      private float width=2;     
      public float Width   
      {   
          get { return this.width; }
          set { width = value; }   
      }           
    }
java

public class Studyingclass
{
private float width=2;
public float getWidth()
{return width;}
public void setWidth(float value)
{this.width=value;}
}
明白了這個就好用了。