3
Answers

use of virtual/override on class variables as I can

Kumar Gaurav

Kumar Gaurav

9y
408
1

Why can't I use virtual/override on class variables as I can on methods?

Like for example we have 2 classes
 
class A
{
public virtual int x;
}
class B : A
{
public override  int x;
}
  when i compile this above code it display error like "The modifier 'virtual' is not valid for this item"???
why display this type of error?? please help me in details . 
Answers (3)