Interface is just another type of the CLR. Interfaces can have members, with the restriction that an interface cannot have instance fields nor instance methods with implementation.
One can view interfaces as partitioning the set of all possible objects into subsets. Which subsets an object belongs to depends on which interfaces the object’s type has declared compatibility with.
The CLR allows the concrete type to declare the methods interface forced as private provided that one uses some mechanism to indicate that the methods are used to satify the requirements of the interface, which hides the method from the concrete type’s public contract. To access the hided methods, one must use a reference of the interface type, which can acces all interface type declared methods. Consider the following example:
namespace EssentialNet
{
interface ICustomer
{
string GetBirthDay();
}
}
namespace EssentialNet
{
public class Customer : ICustomer
{
public static string name;
public static string id = "C1";
public static string code = "XIECH2";
public long t1 = DateTime.Now.Ticks;
public long t2 = DateTime.Now.Ticks;
public long t3;
static Customer()
{
name = "xiech2";
}
public Customer()
{
t3 = DateTime.Now.Ticks;
}
#region ICustomer Members
string ICustomer.GetBirthDay()
{
return "20100101";
}
#endregion
}
}
To access the GetBirthDay method, on must use a reference of type Icustomer.
分享到:
相关推荐
it reviews bioinformatics basics (including database formats, data-types and current analysis methods), and examines key topics in computer science (including data-structures, identifiers and ...
The Open Host Controller Interface (OpenHCI) specification is a standard designed to define the interface between a host controller driver and the hardware of a USB (Universal Serial Bus) host ...
The 1394 Open HCI also includes DMA engines for high-performance data transfer and a host bus interface. IEEE 1394 (and the 1394 Open HCI) supports two types of data transfer: asynchronous and ...
introduction of more integer types and a 32-bit float type (see Section 2.4) to communicate native controller types to the outside, introduction of a binary type to support non-numeric data handling,...
line interface (CLI) and the graphical user interface (GUI). The usual CLI consists of a textual console in which the user types a sequence of commands at a prompt, and the output of the commands is ...
• Explore Swift s object-oriented concepts: variables and functions, scopes and namespaces, object types and instances • Become familiar with built-in Swift types such as numbers, strings, ranges, ...
Activate and add 3rd-party support through the new interface. Again its easy and fast as possible! * Gaia Compatible! * CTS Compatible! * AQUAS Integration! * LUX Water Integration! * FogVolume ...
Understand and use the new Blue Ocean graphical interface Take advantage of the capabilities of the underlying OS in your pipeline Integrate analysis tools, artifact management, and containers
Cocoa and Objective-C: Up and Running offers just enough theory to ground you, then shows you how to use Apple's rapid development tools -- Xcode and Interface Builder -- to develop Cocoa applications...
Understand and create multiple types of reports and dashboards from scratch Assign permissions related to reports and dashboards Get to grips with the Salesforce data architecture and its relation to ...
Currently there are two types of extensions available with MATFOR, they are MATLAB Interface and Tecplot FileIO. MATLAB Interface, a new feature in MATFOR 4.1, provides MATFOR users access to MATLAB ...
In this book, you'll learn about classic I/O APIs (File, RandomAccessFile, the stream classes and related types, and the reader/writer classes). Next, you'll learn about NIO's buffer, channel, ...
Data Types: Primitives and Objects Modifiers Arrays Operators Control Flow Statements Error/Exception Handling Complex Example Interfaces and Inheritance Collections Generics Threads Summary Chapter 3...
Parameters and Values - Standard Parameter and Value Types Varargs Value Collection - Converting varargs to generic values GParamSpec - Metadata for parameter specifications Signals - A means for ...
Chapter 3 Processor Types and Specifications Chapter 4 Motherboards and Buses Chapter 5 BIOS Chapter 6 Memory Chapter 7 The ATA/IDE Interface Chapter 8 Magnetic Storage Principles Chapter 9 Hard Disk ...
types that are part of .NET Standard and how they are related to C#. You will learn about the .NET Standard class library assemblies and the NuGet packages of types that allow your applications to ...
You’ll get up to speed on .NET Core and the latest C# 8.0 additions, including asynchronous streams, nullable references, pattern matching, default interface implementation, ranges and new indexing ...