Now if you're asking whats the difference between Foo and Bar in this example
class Quux
{
public int readonly Foo;
private int bar;
public int Bar
{
get{ return bar;}
}
}
the difference is Foo can only be set by the Quux constructor code (or a field initializer). Bar can only be read by clients of Quux, but the value it delivers can be changed by Quux any time it sees fit.
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
The difference is that the one with just a get will compile ;-).
AFAIK readonly can only be applied to fields
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog http://www.dotnetconsult.co.uk
In C#, what is the difference between a property block that has a readonly
keyword and a get block, versus a property block that has only a get block?
Thanks,
Jon
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.796 / Virus Database: 540 - Release Date: 13/11/2004
[microsoft.public.dotnet.languages.csharp]