Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the most used interfaces in C#? [closed]

Tags:

c#

interface

I tried searching for the most used built-in interfaces in C#, but couldn't find an article, so I thought we may recap here.

Let's use the following convention in the answers:

IinterfaceName1: for this

IinterfaceName2: for that

like image 831
Bart Avatar asked Nov 21 '10 21:11

Bart


People also ask

What are interfaces in C?

An interface contains definitions for a group of related functionalities that a non-abstract class or a struct must implement. An interface may define static methods, which must have an implementation. Beginning with C# 8.0, an interface may define a default implementation for members.

What are interfaces in C# used for?

An interface may not declare instance data such as fields, auto-implemented properties, or property-like events. By using interfaces, you can, for example, include behavior from multiple sources in a class. That capability is important in C# because the language doesn't support multiple inheritance of classes.

What is .NET interface?

An interface is a specification for a set of class members, not an implementation. An Interface is a reference type and it contains only abstract members such as Events, Methods, Properties etc. It contain only declaration for its members and implementation defined as separate entities from classes.

WHAT IS interface and types of interface?

Types of user interfacesgraphical user interface (GUI) command line interface (CLI) menu-driven user interface. touch user interface. voice user interface (VUI)


2 Answers

The top two in my mind have to be ones with language support:

  • IEnumerable<T> (and IEnumerable): for use with foreach and LINQ
  • IDisposable: for resources requiring cleanup, used with using

Beyond that...

  • IComparable<T> and IComparer<T>: for generalized sorting
  • IEquatable<T> and IEqualityComparer<T>: for generalized equality
  • IList<T> and ICollection<T>: for mutable collections
  • IDictionary<T,K>: for lookup collections
like image 149
dahlbyk Avatar answered Oct 23 '22 21:10

dahlbyk


INotifyPropertyChange : For data binding to UI classes in WPF, winforms and silverlight

like image 35
TerrorAustralis Avatar answered Oct 23 '22 21:10

TerrorAustralis