Properties

From CSSEMediaWiki
Jump to: navigation, search

This article relates to properties as implemented in the C# programming language. During a lecture this Semester, we discussed the positives and negatives of properties.

Example

This example is a Rectangle class with two properties.

public class Rectangle
{
   private int m_length;
   private int m_width;
   public int length
   {
       get
       {
           return m_length;
       }
       set
       {
           m_length = value;
       }
   }
   public int width
   {
       get
       {
           return m_width;
       }
       set
       {
           m_width = value;
       }
   }
}

Pros and Cons

Interesting discussion goes here...

Personal tools