Bạn đang xem: Interface c# là gì
An interface is a construct using the keyword “interface” and is similar to an abstract class but without any implementation code. It is implemented using a colon (:) in C#. For example, IDisposabe is an interface that can be implemented by a C# class to clean up the resources used by the objects of that class type. The key features of an interface include:It can be declared within a name space or a class.Its members can be a method, property, event or indexer, but cannot be a constant, field, operator, instance constructor, destructor, type or static member.It cannot be instantiated as an object and cannot be defined with data members.Unlike a class that can inherit only one base class and multiple interfaces, an interface can inherit multiple interfaces only.An interface member has public access by default, which cannot be modified using any access modifiers.Modifiers, such as virtual, override or static, should not be used with an interface member.An interface can be accessed using its fully qualified name, which includes the interface name followed by a dot and the member name.An interface member with the “new” modifier can be used to hide an inherited member with the same name.
Survey: Why Is There Still a Gender Gap in Tech?
Do you work in the tech industry? Help us learn more about why the gender gap still exists in tech by taking this quick survey! Survey respondents will also be entered to win a $100 Amazon Gift Card!
Xem thêm: Tải Game Bán Hàng – Nấu ăn Miễn Phí
Tech moves fast! Stay ahead of the curve with webgiaidap.com!
Join nearly 200,000 subscribers who receive actionable tech insights from webgiaidap.com.