Newbie in c# there are many framework interfaces like iDisposable, Iqueryable,IEnumerable available which have different uses Is there a list available for such system interfaces which can be used as ready reference
an interface-based framework is a framework giving the user/client lib access to interfaces only while actually delivering classes implementing those interfaces. The benefit of this approach consists in giving the implementor full control over the implementation and giving the client a stable API at the same time.
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 is Interface? Interfaces in C# are provided as a replacement of multiple inheritance. Interface contains all abstract methods inherited by classes and structs, which must provide an implementation for each interface member declared.
WELL, below is a quick script I ran to scan my computer's .NET assemblies and find all the interface types defined within them
The output file was 1657 lines long*, so... you might want to narrow your search a bit ;)
Console.Write("Enter a path to write the list of interfaces to: ");
string savePath = Console.ReadLine();
var errors = new List<string>();
using (var writer = new StreamWriter(savePath))
{
string dotNetPath = @"C:\Windows\Microsoft.NET\Framework";
string[] dllFiles = Directory.GetFiles(dotNetPath, "*.dll", SearchOption.AllDirectories);
foreach (string dllFilePath in dllFiles)
{
try
{
Assembly assembly = Assembly.LoadFile(dllFilePath);
var interfaceTypes = assembly.GetTypes()
.Where(t => t.IsInterface);
foreach (Type interfaceType in interfaceTypes)
{
writer.WriteLine(interfaceType.FullName);
Console.WriteLine(interfaceType.FullName);
}
}
catch
{
errors.Add(string.Format("Unable to load assembly '{0}'.", dllFilePath));
}
}
}
foreach (string err in errors)
{
Console.WriteLine(err);
}
Console.ReadLine();
*And to be honest, I don't even know how comprehensive this approach was.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With