Interface Implementation

Định nghĩa Interface Implementation là gì?

Interface ImplementationGiao diện thực hiện. Đây là nghĩa tiếng Việt của thuật ngữ Interface Implementation - một thuật ngữ thuộc nhóm Technology Terms - Công nghệ thông tin.

Độ phổ biến(Factor rating): 5/10

Thực hiện giao diện, trong C #, đề cập đến thừa kế một giao diện bởi một struct hay class cung cấp các chức năng cho các thành viên khai báo trong giao diện. Các thành viên của giao diện thực hiện có thể bao gồm các phương pháp, tài sản, indexers và chung events.In, một giao diện đại diện cho một hợp đồng mà phải được tôn trọng bởi một lớp hoặc struct mà cụ tất cả các thành viên quy định trong giao diện. Những lợi ích quan trọng của việc thực hiện giao diện bao gồm linh hoạt, khớp nối thấp, sự gắn kết cao và đa hình behavior.In C #, thực hiện giao diện cho phép một lớp học để kế thừa từ nhiều giao diện thay vì nhiều lớp để nhiều hơn một hành vi có thể được thừa hưởng thông qua nhiều giao diện rằng phương pháp phần chữ ký duy nhất. Giao diện có thể được thực hiện như tài sản để xác định xem tài sản được đọc-ghi, chỉ đọc hay ghi-only. Một giao diện có thể được thực hiện một cách rõ ràng để ẩn một thành viên và thay thế nó với người khác. Không giống như trong Java, rõ ràng giao diện thực hiện C # ‘s cho phép nhiều giao diện với tên phương pháp tương tự và chữ ký, có triển khai khác nhau mà không bất kỳ tên cuộc đụng độ và cung cấp kết quả khác nhau dựa trên các diễn viên hiện tại của đối tượng.

Xem thêm: Thuật ngữ công nghệ A-Z

Giải thích ý nghĩa

Tương tự như một lớp trừu tượng, một giao diện không cung cấp một cài đặt mặc định. Một thành viên của một lớp học hoặc struct mà cụ thành viên của một giao diện phải được công khai, không tĩnh và có cùng tên và chữ ký như trong giao diện. Ví dụ, một giao diện IAccount có thể được thực hiện bởi một lớp, SavingAccount mà thực hiện các thành viên của IAccount có thể bao gồm BalanceAmount, DateOfOpening, vv như các thuộc tính và phương thức của nó như PrintStatement, CalculateInterest, thực hiện etc.Interface có thể tiềm ẩn khi một lớp cơ sở của một lớp được thừa kế đã thực hiện giao diện. Tất cả các giao diện cơ sở không cần phải được xác định một cách rõ ràng trong danh sách lớp cơ sở của lớp dẫn xuất. Bên cạnh đó, các lớp được thừa kế có thể thay đổi hành vi giao diện mà đã được xác định đã có trong lớp cơ sở bằng cách ghi đè các thành viên ảo trong việc thực hiện class.Interface có nguồn gốc rõ ràng là khi các thành viên của hai hay nhiều giao diện có cùng tên với cùng một chữ ký nhưng thực hiện hai chức năng khác nhau, được thừa kế bởi một lớp hoặc struct mà cụ từng thành viên một cách rõ ràng. một thành viên đó được đặt tên với tên của giao diện và một khoảng thời gian và chỉ có thể được truy cập chỉ thông qua một thể hiện của giao diện. Không giống như các phương pháp ngầm, phương pháp rõ ràng không thể trừu tượng hoặc ảo.

What is the Interface Implementation? - Definition

Interface implementation, in C#, refers to the inheritance of an interface by a struct or class that provides the functionality for the members declared in the interface. The members of the implemented interface can include methods, properties, indexers and events.In general, an interface represents a contract which has to be adhered by a class or struct that implements all the members specified in the interface. The key benefits of interface implementation include flexibility, low coupling, high cohesion and polymorphic behavior.In C#, interface implementation allows a class to inherit from multiple interfaces instead of multiple classes so that more than one behavior can be inherited through multiple interfaces that share method signatures only. Interface can be implemented as property to specify whether the property is read-write, read-only or write-only. An interface can be implemented explicitly to hide a member and replace it with another. Unlike in Java, C#‘s explicit interface implementation allows multiple interfaces with same method name and signatures, to have different implementations without any name clash and provide different result based on the current cast of the object.

Understanding the Interface Implementation

Similar to an abstract class, an interface does not provide a default implementation. A member of a class or struct that implements a member of an interface must be public, non-static and possess the same name and signature as that in interface. For example, an interface IAccount can be implemented by a class, SavingAccount which implements the members of IAccount that can include BalanceAmount, DateOfOpening, etc. as its properties and methods like PrintStatement, CalculateInterest, etc.Interface implementation can be implicit when a base class of a derived class already implements the interface. All the base interfaces need not be explicitly specified in the base class list of the derived class. In addition, the derived class can change the interface behavior that has been defined already in the base class by overriding the virtual members in the derived class.Interface implementation is explicit when members of two or more interfaces having same name with same signature but performing two different functions, are inherited by a class or struct that implements each member explicitly. Such a member is named with the name of the interface and a period and can only be accessed only through an instance of the interface. Unlike implicit methods, explicit methods cannot be abstract or virtual.

Thuật ngữ liên quan

  • Interface (I/F)
  • Multiple Inheritance
  • Class
  • Method
  • Indexer
  • Event
  • Abstract Class
  • Cast
  • Commit
  • Access Modifiers

Source: ? Technology Dictionary - Filegi - Techtopedia - Techterm

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *