How to compare two generic lists in C# 3.0?
Possible Duplicate: Is there a built-in method to compare collections in C#? What is the best way to compare to generic two generic lists in C# 3.0? ...
Possible Duplicate: Is there a built-in method to compare collections in C#? What is the best way to compare to generic two generic lists in C# 3.0? ...
I'm currently rewriting parts of a custom RPC mechanism (which cannot be replaced by something else, so don't suggest that ;-) ). The arguments of a call are collected in a custom collection that uses a dictionary internally. There is a method T Get<T>(string) to retrieve a named argument. For optional arguments, I wanted to add a TryGet...
I am sure I am missing something simple, however I am trying to convert a strongly typed list of objects that all implement an interface in to a list of that interface type. Below is a sample to demonstrate the error: public void ExampleCode(){ List<Cube> cubes = new List<Cube>(); List<Shape> allShapes; allShapes = cubes;/...
Hi there, I was thinking of implementing a per-object Repository (e.g. a Person repository, a State repository etc.) before deciding on a line of business Repository instead BUT I still have a question regarding the passing in of an ID (identifier) type with a generic. In a nutshell, a Person may have a GUID identifier, a State/County ...
Most of the documentation regarding type erasure handling in Java assumes that the use case is handling a type like SomeType<ParamType>. I am trying to process method parameter for the following method: public void setOtherReferenceRanges(List<ReferenceRange<T>> referenceRanges) When the container class is instantiated with a type DvQ...
Hi, I am very new to Scala. I want to implement a generic matrix class "class Matrix[T]". The only constraint on T should be that T should implement a "+" and a "*" mothod/function. How do I go about doing this? For example I want to be able to use both Int, Double, and my own defined types e.g. Complex I was thinking something along ...
I have my domain model with several NewsType's which are subclasses of NewsItem as shown below (simplified): public abstract class NewsItem : Entity { public virtual Account Account { get; set; } public virtual DateTime DateTime { get; set; } } Here are a couple of subclasses of NewsItem: public class NewsItemJoiner : NewsIte...
I have a code piece that looks something like what I've pasted below: import java.util.LinkedHashMap; import java.util.Map; public class GenericMagic { GenericMagic() { } private class Container { int doSomething(){ return 42;} @Override public String toString() { return "Container"+doSomething(); } } ...
All, I've got a generic list defined in a custom user control. private List<string> m_AnimationNames = new List<string>(); public List<string> AnimationNames { get { return this.m_AnimationNames; } set { this.m_AnimationNames = value; } } I reference this list in xaml, and populate it, like so...
I wanted to create an application which tracks four different colored blobs from video feed from the webcam and outputs the x and y co-ordinates of the blob. I would prefer if I code this in Visual C++ but if that is not the best language to use I wouldn't mind exploring some other language. I also stumbled upon OpenCV which seems to be ...
Consider the following classes (please assume public getter and setter methods for the private fields). // contains a bunch of properties public abstract class Person { private String name; } // adds some properties specific to teachers public class Teacher extends Person { private int salary; } // adds some properties specific to stu...
I've been teaching myself LINQ recently and applying it to various little puzzles. However, one of the problems I have run into is that LINQ-to-objects only works on generic collections. Is there a secret trick/ best practice for converting a non-generic collection to a generic collection? My current implementation copies the non-generi...
In Entity framework, would the statement MyDataContext.Products.OrderByDescending( (p) => p.Id ).GroupBy<Product,int>( (p) => p.ProductId ).Select( (g) => g.FirstOrDefault()).Where( (p) => p.Name.Equals("Something") ); result in another database query than MyDataContext.Products.Where( (p) => p.Name.Equals("Something") ).OrderByDesce...
Hello, I have a doubt, sometime I made this conversion from DataTable to List (C# code): List<EDog> lstDogs = (from drRow in dsDogs.Tables[0].AsEnumerable() select new EDog() { ...
I'm trying to do something like this, but Java won't let me. I suspect that I am just doing something wrong, but I really have no idea what. public interface PopulationMember extends Comparable<T extends PopulationMember> { int compareTo(T o); T merge(T o); // Some other stuff } It seems to think that T should be a class...
Hi, I need to use a generic interface like the following: public interface IContainer<T> { IEnumerable<IContent<T>> Contents { get; } } An object implementing this interface is returned by a generic method like the following: IContainer<T> GetContainer<T>(IProperty property); Type T is unknown until run-time. Using reflection...
I have a data structure defined as: Dictionary<Guid, List<string>> _map = new Dictionary<Guid, List<string>>(); I'm trying to create a lambda expression that given a string, returns a IEnumerable of Guids associated with any List<string> containing that string. Is this reasonable/possible or should I use a more appropriate data...
Here is what I would like to write in my java code: private <A extends Action<R>, R extends Result> MyType<A,R> member; This is invalid syntax however. So I end up writing: private MyType<? extends Action<? extends Result>, ? extends Result> member; But this disregard the fact that both classes derived from Result are the same. My ...
I have created this method which is an object factory: public static T GetService<T>(T serviceInterface) { if (serviceInterface.Equals(typeof(IMemberService))) { return (T)(object)new MemberService(); } else if (serviceInterface.Equals(typeof(ILookupService))) { return (T)(object)new LookupService(); ...
I'm creating an anonymous List<> here: var pip = new { MCP = "", Measure = "", Year = "", url1 = "", url2 = "", url3 = "" }; var PipList = (new[] { pip }).ToList(); The I loop through my code and load that list with items and bind it to my gridview: PipList.RemoveAt(0); gvReport.DataSource = PipList; gvReport.DataBind(); When I de...