D vs. C#

Julio César Carrascal Urquijo jcarrascal at gmail.com
Sun Oct 21 08:26:08 PDT 2007


Janice Caron wrote:
> Also, the fact that one can write a getter function without a setter
> function allows one to define properties which are read-only to the
> outside world, but read-write to the containing object, which again is
> something you can't do with a plain member variable.

In C# you can:

	class Foo
	{
		public readonly string Bar = "Hello";

		// or
		public string Baz
		{
			get { return m_bar; }
		}
	}

The first one is read-only everywhere. The second is read-only in the 
outside but member functions can change the value of m_bar. I still miss 
read-only local variables, though.

--
Julio César Carrascal Urquijo
http://www.artelogico.com/



More information about the Digitalmars-d mailing list