concept interface in category .net

This is an excerpt from Manning's book C# in Depth.
That’s an improvement, but it’d be nice if you could sort the products by simply specifying the comparison to make, without needing to implement an interface to do so. The following listing shows how to do precisely this, telling the Sort method how to compare two products using a delegate.
Listing 7.1. Demonstration of mixing declarations of a partial type
// Example1.cs using System; partial class Example<TFirst, TSecond> : IEquatable<string> #1 where TFirst : class { public bool Equals(string other) #2 { return false; } } // Example2.cs using System; partial class Example<TFirst, TSecond> : EventArgs, IDisposable #3 { public void Dispose() #4 { } } #1 – 1 Specifies interface and type parameter constraint #2 – 2 Implements IEquatable<string> #3 – 3 Specifies base class and interface #4 – 4 Implements IDisposable !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[]"} !@%STYLE%@!
These have both been simple examples using single-method interfaces, but the same principles apply for more complex APIs. Of course, the more complex the interface is, the more likely that a type parameter will be used for both input and output, which would make it invariant. We’ll come back to some tricky examples later, but first we’ll look at delegates.

This is an excerpt from Manning's book Dependency Injection in .NET.
Program to an interface, not an implementation.
Usually, we don’t wire electrical appliances together by attaching the cable directly to the wall. Instead, as in figure 1.5, we use plugs and sockets. A socket defines a shape that the plug must match. In an analogy to software design, the socket is an interface.
That’s the easy part. Programming to an interface instead of an implementation is easy. The question is, where do the instances come from? In a sense, this is what this entire book is about.
You can’t create a new instance of an interface the same way that you create a new instance of a concrete type. Code like this doesn’t compile:
![]()
An interface has no constructor, so this isn’t possible. The writer instance must be created using a different mechanism. DI solves this problem.

This is an excerpt from Manning's book IronPython in Action.
>>> import System.Collections
>>> interfaces = [entry for entry in dir(System.Collections)
... if entry.startswith('I')]
>>> for entry in interfaces:
... print entry
...
ICollection
IComparer
IDictionary
IDictionaryEnumerator
IEnumerable
IEnumerator
IEqualityComparer
IHashCodeProvider
IList
>>>
IronPython programs use .NET classes natively and seamlessly, and there are lots of classes. Two of the gems in the collection are Windows Forms and WPF, which are excellent libraries for building attractive and native-looking user interfaces. As a Python programmer, you may be surprised by how straightforward the programmer’s interface to these libraries feels. Whatever programming task you’re approaching, it’s likely that there’s some .NET assembly available to tackle it. As well as the standard libraries that come with the framework, there are also third-party libraries for sophisticated GUI components, such as data grids, that don’t have counterparts in CPython.
Interfaces are a way of specifying that certain types have known behavior. An interface defines functionality, and the methods and properties for that functionality.
Where a class implements an interface, that interface will be added to the method resolution order[30] when you use it from Python (effectively making the interface behave like a base class—coincidentally you can also implement an interface in a Python class by inheriting from it). Even if an explicitly implemented interface method is marked as private on a class, you’ll still be able to call it.
Interfaces are used in C# to specify behavior of objects. For example, if a class implements the IDisposable interface, then you can provide a Dispose method to release resources used by your objects. .NET has a whole host of interfaces, and you can create new ones. If a class implements an interface, it provides a static target for the compiler to call whenever an operation provided by that interface is used in your code.

This is an excerpt from Manning's book ASP.NET AJAX in Action.
The goal of the type system is to introduce familiar object-oriented programming concepts to JavaScript—like classes, inheritance, interfaces, and event-handling. This layer also extends existing JavaScript types. For example, the String and Array types in JavaScript are both extended to provide added functionality and a familiarity to ASP.NET developers. The type system lays the groundwork for the rest of the Ajax core library.
An interface allows an object to know what another object can do, without knowing how. An interface is said to define a contract between a class and the outside world. Interfaces are different from classes in the sense that they define a list of methods and properties that a class must expose, but it’s the class’s responsibility to provide an implementation. Listing 3.11 contains the declaration of an interface called IComparable that exposes a single method, compareTo, which performs a generic comparison between objects.
To define the interface, you start by creating a JavaScript function. Because you’re dealing with an interface type, you need to prevent the function from being used as a constructor. To do this, you throw a client exception of type notImplemented as soon as you try to call the function.
The same thing must be done for the methods defined by the interface. When a client class implements an interface, its methods are copied into the constructor’s prototype. As a consequence, a client exception of type notImplemented will be thrown if you don’t override the implementation of the method. This is how interfaces work in the Microsoft Ajax Library.
The final step is to register the interface by calling the registerInterface method on the interface type. The only argument accepted by the method is a string with the fully qualified name of the interface. The call to registerInterface ensures that the interface is properly recognized by the type system.