Can we declare abstract keyword on fields in a class ?

 Posted by Akiii on 5/30/2012 | Category: C# Interview questions | Views: 2660 | Points: 40
Answer:

No we cannot.

For example :-

public abstract class clsbase

{
public abstract string str = "Akiii";
}


executing the code will results in the following error :-
Error 1 The modifier 'abstract' is not valid on fields. Try using a property inste ad.


Thanks and Regards
Akiii


| Alert Moderator 

Comments or Responses

Login to post response