What is ildasm?
Why generics?
- defer type specification to client
What is a List?
What is Queue?
What is Stack?
What is a Hashset?
What is LinkedList?
What is Dictionary?
What is the T?
What are “Sorted” collections?
What does Compare typically do?
How can you convert types?
How do you return data when building your own Enumerator?
What is included in method signature?
What are extension methods?
- first parameter is “this IBuffer buffer”
3 basic .NET delegate types often used
Can you constrain generics?
ex.
IBuffer where T: class, IInterface, new()
How do you set a generic to it’s default value?
T result = default(T);
What is “out” keyword for generics?
What is Contravariance?
What is invariant?
Repo Example using Covariance and Contravariance
Person -> Employee -> Manager
public interface IReadOnlyRepo : IDisposable
{
T FindById(int id);
IQueryable FindAll();
}public interface IWriteOnlyRepo : IDisposable
{
void Add(T newEntity);
void Delete(T entity);
int Commit();
}public interface IRepo : IReadOnlyRepo, IWriteOnlyRep
{
}
public class SqlRepo : IRepo where T: class, IEntity
{
}What is an Unbound Generic?
can only be used in typeof operator
Generics and Reflection example
static method to create a list
private static object CreateColl(Type collType, Type itemType)
{
var closedType = collectionType.MakeGenericType(itemType);
return Activator.CreateInstance(closedType);
}