Hi all,
public IList<T> GetClientsByListofID<T>(IList<int> ids) where T : IClient
{
IList<T> clients = new List<T>();
clients.Add( new Client(3));
}
I am getting a compiler error here:
cannot convert from 'Bailey.Objects.Client' to 'T'
The client object implements the IClient interface. My goal here is to try and loosen t...
Dear ladies and sirs.
I have this little problem, that I cannot figure out which arguments to pass to Type.GetMethod in order to get back the MethodInfo of a generic method on a non generic type.
Specifically, I have this type definition:
public static class A
{
public static B F<T>(bool dummy)
{
}
public static B F<T>(IEnumera...
I want to create a simple generic function
void Assign<T>(out T result)
{
Type type = typeof(T);
if (type.Name == "String")
{
// result = "hello";
}
else if (type.Name == "Int32")
{
// result = 100;
}
else result = default(T);
}
Usage:
int value;
string text;
Assign(value); // <<< should set value to 100
...
Hi,
I am trying to use the MethodInfo MakeGenericMethod as follows:
foreach (var type in types)
{
object output = null;
var method = typeof (ContentTypeResolver).GetMethod("TryConstruct");
var genmethod = method.MakeGenericMethod(type);
var arr = new object[] { from, outpu...
Given the following Interfaces:
interface IEntity
{
int Id{get;}
}
interface IPerson : IEntity
{
string Name{get;}
int Age{get;}
}
interface ITeacher : IPerson
{
string StaffId{get;}
}
interface IStudent : IPerson
{
string StudentId{get;}
string Courses{get;}
}
interface IRepository
{
T Get<T>(int id)...