Interviews17 answers
Can you declare variable in interface
17 Answers
No
Yogesh SevankarPosted Oct 17, 2019, 10:33 PM EDT
Well now, starting from C# 8.0 preview version you can declare variables in interface
Default implementation of methods in interface
As well as body methods
Ishoo AnyalPosted Sep 28, 2019, 1:19 AM EDT
No,we cannot declare variable inside interface. We can declare property in Interface.
sushil kumarPosted Mar 10, 2019, 8:54 PM EDT
NO
Udit ChauhanPosted Jul 18, 2018, 12:05 AM EDT
No you can not declare variable in interface.
VINAY MISHRAPosted Jun 12, 2018, 3:33 AM EDT
No, we cannot declare variables, methods, properties, and constructors in the interface
Mounika ChandrapatiPosted Jun 11, 2018, 8:19 AM EDT
No, we can't declare variables, constructors, properties, and methods in the interface.
Mounika ChandrapatiPosted Jun 11, 2018, 7:56 AM EDT
No, you can not declare 'variable' in interface.Also interface can not contain 'operators'.
I have written blogs on interface that will helps you to understand the concept of interface. You can visit on following link
https://www.c-sharpcorner.com/blogs/interface-in-c-sharpnet-simple-way-part-one
Shrimant TelgavePosted May 2, 2018, 4:55 AM EDT
interface cannot contains fields
Pravinkumar BirajdarPosted Apr 9, 2018, 9:37 PM EDT
No.you cannot declare variables in an interface as interface can only contain the signatures of methods, properties, events or indexers
Akbar MullaPosted Mar 19, 2018, 8:52 PM EDT
no,interface cannot contains fields.
Satish SanaboyinaPosted Mar 15, 2018, 6:33 PM EDT
We cant declare fields inside the Interface.
Note : We can declare abstract properties and functions inside Interface.
Sreekanth ReddyPosted Mar 8, 2018, 6:22 PM EST
No, it doesn't mean that. The interface doesn't actually contain the property, either.
Remember than interface has to be implemented by a class in order for you to use it. An interface only defines a contract, meaning that any class that implements that interface will have all of the members defined by the interface. The interface doesn't actually have those members; it's more like a template. The instance of the class that implements the interface is the one that contains the property, and therefore the private backing field used for the property.
Interfaces can only define signatures for the following members:
Methods
Properties
Indexers
Events
Bharathi RajaPosted Jan 31, 2018, 11:37 PM EST
no
bebo beboPosted Nov 25, 2017, 6:12 AM EST
When you declare a variable, it will give "Interface can not contain a field" which means you can;t declare a variable in an interface. So answer is No, we Can't.
Ashish GopePosted Nov 23, 2017, 12:16 AM EST
no
Gopisetty VvsskiranPosted Nov 15, 2017, 8:25 PM EST
No
Mukesh KumarPosted Aug 21, 2017, 7:52 AM EDT








