Hi,
I have a class that needs to use a Class<T> parameter (see my previous semi-related question). It is:
public class BaseTable<T extends TableEntry>
{
protected Class<T> mClass;
...
public BaseTable(int rows, int cols, Class<T> clasz)
{
...
mClass = clasz;
}
public BaseTable(int rows, int col...
what is the benefits and disadvantages of using generic methods( in compile time and run time, in performance and memory)?
...
Hello all,
I've been looking around to see if I find something to help me with my problem, but no luck until now. I've got the following classese:
public interface ISort<T> {
public List<T> sort(List<T> initialList);
}
public abstract class Sort<T> implements ISort<T> {
private Comparator<? super T> comparator;
p...
I have a generic method
bool DoesEntityExist<T>(Guid guid, ITransaction transaction) where T : IGloballyIdentifiable;
How do I use the method in the following way:
Type t = entity.GetType();
DoesEntityExist<t>(entityGuid, transaction);
I keep receiving the foollowing compile error:
The type or namespace name 't' could
not be...
I'm doing something like this:
public abstract class FolderNode<TChildNode,TChildBusObj> : Node
where TChildNode : MappedNode<TChildBusObj>, new()
where TChildBusObj : new()
{
..
}
Is there a way of omitting TChildBusObj from the definition, but still be able access it in the code? E.g. I want to be able to infer the generic t...
How could I make a List in PowerShell 2?
I've tried these:
[activator]::createinstance(([type]'system.collections.generic.list`1').makegenerictype([string]))
and
[activator]::createinstance(([type]'system.collections.generic.list`1').makegenerictype([string]))
and all I get is just nothing. What's going wrong?
I'm running XP SP3,...
I am getting an error when trying to use a Type parameter when specifying the Type for a generic method.
Error: 'JsonFilter.JsonDataType' is a 'property' but is used like a 'type'
public class JsonFilter : ActionFilterAttribute
{
public Type JsonDataType { get; set; }
public override void OnActionExecuting(ActionExecutingCo...
I have several database - Elephants, Giraffes, Gorillas, etc - each of which has an Inputs and Results table named ElephantInputs, ElephantResults, GiraffeInputs, GiraffeResults, GorillaInputs, GorillaResults, respectively. I can't control the table naming.
I'm using LINQ to SQL to automatically generate the ElephantInputs, ElephantResu...
My unit tests are doing something very strange when I call a method of a generic base type. I have tried both NUnit and MSTest with the same result. This is how the code is organized:
public class MyStub {}
public class EnumerableGenerator
{
public bool GotMyStubs;
public IEnumerable<MyStub> GetMyStubs()
{
GotM...
I was writing something using generics and to my surprise I found that this doesn't work:
class foo<T>{
T innerT = new T();
}
So can't I instantiate the genericized type? Aren't there any ways to do this?
...
I am wanting to sort a Generic List in Ascending Date order.
(Framework v2)
Any suggestions?
Thanks
...
Could I have something like this:
int x = MyMethod<int>();
string y = MyMethod<string>();
So, one method returning different types based on T. Of course, there would be logic inside the method to ensure it was returning the correct thing.
I can never get something like this to run. It complains that it can't cast the return value t...
Hi!
I have base class:
class ARBase<T> : ActiveRecordValidationBase<T> where T : class
{
}
and few child classes
class Producent : ARBase<Producent>
{
}
class Supplier : ARBase<Supplier>
{
}
Now in other class I want to have Property of type:
public IList<ARBase<Object>> MyCollection
{
}
and want to be able to assign collecti...
The other day I built a user control that dynamically builds a data display from a given custom business object.
It works well but I'd like to use the control in other applications and the way it is currently encapsulated is sub par.
My custom user control just contains the basic html controls and a few internal properties so I can ac...
Why does this conversion not work?
public interface IMyInterface
{
}
public interface IMyInterface2 : IMyInterface
{
}
public class MyContainer<T> where T : IMyInterface
{
public T MyImpl {get; private set;}
public MyContainer()
{
MyImpl = Create<T>();
}
public static implicit T (MyContainer<T> myCon...
I've got an abstract class like this;
public abstract PropertyBase
{
public static System.Type GetMyType()
{
return !!!SOME MAGIC HERE!!!
}
}
I'd like to subclass it, and when I call the static GetMyType(), I'd like to return the subclass's type. So if I declare a subtype;
public class ConcreteProperty: PropertyBase...
When binding WPF Toolkit DataGrid to SQL database through LINQ to SQL, how to correctly set binding source:
should it be some generic collection, filled and updated by LINQ to SQL queries or there is a possibility to directly connect DataGrid with LINQ to SQL queries?
...
Why cant I use an IEnumerable with params? Will this change in the future?
...
Hi,
I have a genericised class that I wish to subclass as follows:
public class SomeTable<T extends BaseTableEntry>
extends BaseTable<T>
{
public SomeTable(int rows, int cols)
{
super(rows, cols, SomeTableEntry.class);
//Does not compile:
//Cannot find symbol: constructor BaseTable(int, int, java.la...
I have a C# dictionary, Dictionary<Guid, MyObject> that I need to be filtered based on a property of MyObject.
For example, I want to remove all records from the dictionary where MyObject.BooleanProperty = false. What is the best way of acheiving this?
...