Subject: Re: Set readonly in constructor of a derived class.
Date: Tue, 7 Oct 2003 05:01:26 -0400
Lines: 78
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Message-ID: <#7#
[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 66.188.59.114.bay.mi.chartermi.net 66.188.59.114
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189475
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
Thanks Peter. I understand the normal usage of readonly. However I am
asking a different question. As Derived inherits "sharedObject", and Base1
is abstract, isn't "sharedObject" a member of the Derived class? And if so,
why can't the *constructor in Derived set the value in its' constructor?
--
William Stacey, MVP
Peter Huang said:
Hi William,
The readonly keyword is a modifier that you can use on fields. When a field
declaration includes a readonly modifier, assignments to the fields
introduced by the declaration can only occur as part of the declaration or
in a constructor in the same class.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here is the link for detail information.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html
/