[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DotGNU]C# properties virtual by default?
From: |
Rhys Weatherley |
Subject: |
Re: [DotGNU]C# properties virtual by default? |
Date: |
Sat, 20 Apr 2002 08:59:57 +1000 |
S11001001 wrote:
> Something has come up in development, as I have considered subclasses. Are
> properties virtual by default?
Nope. They are just like fields. The following is a
non-virtual instance property:
public int Name { get { ... } }
However, there is a small wrinkle in C#. If the class
is implementing an interface that declares a property
or method, then the definition in the class will get the
virtual attribute automatically. e.g.
interface I
{
int Name;
}
class A : I
{
public int Name { get { ... } }
}
In this case, the declaration in A is virtual.
Cheers,
Rhys.