Monday, September 1, 2014

Properties

Hi,



private string[] arr = new string[100];
// with an indexer you can encapsulate an internal collection or array.
public string this[int i]
{
get
{
return arr[i];
}
set
{
arr[i] = value;
}
}


private string val;
// With a property you can read, write, or compute the value of a private field.
public string Val
{
get
{
return val;
}
set
{
val = value;
}
}

For more information and a detailed cpmparison have a look at http://ift.tt/1no02v6




Chris



Code Samples: Code Samples

Chrigas Blog: Chrigas Blog


No comments:

Post a Comment