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
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.
Well, many are very bespoke to specific purposes. If you listed all of them it would take a while.
The main ones I'd add to the above are IList
/IList<T>
(sets/collections/lists), IDictionary<TKey,TValue>
, IEnumerable<T>
(generic version of IEnumerable
), and IEnumerator
(plus generic twin, although in truth few people need to code against IEnumerator
).
If you want into any area, there would be many many more that you'll meet quickly - things like IDbCommand
/IDataReader
for data-access, etc - but it isn't just interfaces that are important. Things like Stream
is a class (albeit abstract), but hugely important.
I think a better question/tactic might be "given that I'm doing [specific X], what are the important types to know about?". Since we don't know the [specific X], we can't answer that much.
Here is a .NET Framework Class Library documentation
http://msdn.microsoft.com/en-us/library/ms229335.aspx
By clicking on selected namespace you will see interfaces defined in that namespace. In my humble oppinion such categorized list is much more comfortable to use as reference than just simple list of interfaces.
Here is some LINQ to get a collection of interfaces, where "files" is an array of libraries to search.....
var interfaces = (from fileName in files
select Assembly.LoadFile(fileName)
into assembly
select assembly.GetTypes()
into typesInAssembly
from interfacesInType in typesInAssembly.Select(type => type.GetInterfaces())
from interfaceInType in interfacesInType
select interfaceInType)
.Distinct()
.OrderBy( i => i.Name);