How can I instantiate a IList<T> of nested IList<T>?
I am trying to create a list of lists but am having trouble instantiating the list. IList<IList<T>> allLists = List<List<T>>(); I am getting a compile error with this line. ...
I am trying to create a list of lists but am having trouble instantiating the list. IList<IList<T>> allLists = List<List<T>>(); I am getting a compile error with this line. ...
Hello. I have an abstract class AbstractEvent and some "real" classes extending it. I want to make an abstract class AbstractListener with a method process(??? event) so that non-abstract classes extending AbstractListener would be required to have at least one method accepting a class extending AbstractEvent. Is that possible? ...
I have an enum for one of the properties of my view-model. I want to display a drop-down list that contains all the values of the enum. I can get this to work with the following code. What I'm wondering is whether there is a simple way to convert from an enum to an IEnumerable? I can do it manually as in the following example, but wh...
For my bussiness purpose I want to take a Two letter domain name(eg: xx.yy). Where do I get this? I think GoDaddy.com don't support two letter domain names? my name is not yet registered, thank god Its available!!!! ...
I have dictionary that gives me back a method according to the value passed in. Defined as so: Dictionary<Type, IXmlWriterConverter> I have now added a new function that which has the Key/type set to IEnumerable, so far so good. But when I execute my unit test with a List containing two DataTables but the dictionary can not find the k...
Hello Everyone. I am trying to create a little functional programming library for Java (just to scratch my own itch). While defining the higher-order functions for Lists, Sets and Maps I have come across this problem: The functions that take a collection, and return a collection of same type have almost the same implementation, and yet ...
Hi all, Is there a way to define the following structure in a DataContext/DBML file? public class Entity { public int Id { get; set; } public string Name { get; set; } public EntitySet<IPermission> Permissions { get; set; } } public class User : IPermissionHolder { public int Id { get; set; } public string Name { ge...
Given the following model which has a name, url, and an arbitrary list of keywords (I want the user to add a series of keywords) ... public class Picture { public Picture() { keywords = new List<string>(); } public string name {get;set:} public string url {get;set;} public List<string> keywords{get;set;} } ... and the ...
I'm using a third party library that returns a raw Iterator, e.g. Iterator<?> children = element.getChildElements(); I know the actual type, but I don't necessarily trust the third party lib to stick with it in the future. There are two (that I can think of) somewhat risky ways to traverse this: @SuppressWarnings("unchecked") Iterat...
I want to create a generic list of the Type object. I have ... Type type = typeof(Foo); object model = GetModel(); Now I want to create a new List<Foo>((Foo)model) Is this possible in C#? ...
Consider the following. You have a class that you want to serialize with XmlSerializer which has a public generic method with a type constraint where the type is in a different assembly: using BarStuff; namespace FooStuff { public class Foo { ... public T GetBar<TBar, T>( string key ) where TBar : Bar<T> { ... } ...
hi there I've got a trait that looks like this (some further information can be found at this related question by myself although I don't think, it's needed for this question) trait Extractor[-A,+B] { def extract(d:A):B //lots of other things } To use this in an existing java framework I would like this Extractor to either have a...
Why this code does not compile (Parent is an interface)? List<? extends Parent> list = ... Parent p = factory.get(); // returns concrete implementation list.set(0, p); // fails here: set(int, ? extends Parent) cannot be applied to (int, Parent) ...
I don't think this is possible but here goes... I want to add method that can handle n numer of generics. for example : bool<T> MyMethod() where T: Isomething { } will work for one type bool<T,K> MyMethod() where T: Isomething { } will work for two types Is there a way to work with n types - e.g. bool<T[]> MyMethod() where T: ...
Does JPA support embedding a class attribute whose type is a parameterized generic or java.lang.Object? For example: public class Foo<T>; { private T param1; private Object param2; } I have a use case where I have a class that "wraps" some arbitrary class (the generic T or java.lang.Object) via aggregation plus contains pr...
namespace Test { #region Not my code public interface IAdditional { } public interface ISome { ISomeOther<T> GetSomeother<T>() where T : class; } public interface ISomeOther<T> where T : class { void DoFoo(T obj); } public class AnotherClass<T> where T : class { } pu...
Since I am using two different generic collection namespaces (System.Collections.Generic and Iesi.Collections.Generic), I have conflicts. In other parts of the project, I am using both the nunit and mstest framework, but qualify that when I call Assert I want to use the nunit version by using Assert = NUnit.Framework.Assert; Which w...
I have two classes: a base class (Animal) and a class deriving from it (Cat).Base class contains one virtual method Play that takes List as input parameter.Something like this using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication9 { class Animal { public virtu...
I have these two Haskell data types: data Code = Code_A | Code_B | Code C deriving (Eq,Show) data ListObject = Code | Int I need to make a list that contains ListObjects. That is both integer values and codes ([1,2, Code_A, 3]). I know it should be possible but I just can't figure the syntax for it. Haskell can do some neat ...
Hi, what I'm trying to do is send a generic method(filter) inside generic object(ItemDelegate) to another generic method(getItem). The problem is that the second method(getItem) can not infer the correct type. // Generic object public class ItemDelegate<T> { public <T> T filter() { return null; } } // Generic method (r...