Sarmad Rehman

Sarmad Rehman

  • NA
  • 16
  • 598

Write Only Property

Jul 12 2017 2:04 PM
using System;
namespace Tester
{
public class MyClass
{
private int _age;
public int Age
{
set
{
this._age = value;

}
}

} // MyClass ends here.

class Program
{
static void Main()
{
MyClass MC = new MyClass();
int i = MC.Age = 19;
Console.WriteLine(i);
Console.ReadLine();
}
}
}
 
I have only set accessor but i can still read the value of age. how i can implement write only property which cannot be read.
 

Answers (5)