During a refactoring, I added a generic type parameter to MyControl, a class derived from UserControl. So my class is now MyControl<T>.
Now I get an error at runtime stating that the embedded resource file MyControl`1.resources cannot be found. A quick look with reflector shows that the resource file is actually called MyControl.resourc...
Given the following vb.net class:
Friend Class PairCollection(Of TKey, TValue)
Inherits List(Of KeyValuePair(Of TKey, TValue))
Public Overloads Sub Add(ByVal key As TKey, ByVal value As TValue)
Me.Add(New KeyValuePair(Of TKey, TValue)(key, value))
End Sub
Public Function FindByValue(ByVal value As TValue) As Li...
I'm trying to override equals() for a parametrized class. How can I make sure that this parameter is the same?
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
* Because this is commutative, `Tuple(a0, a1)` is the same as `Tuple(a1, a0)`
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true...
I have this function:
Program A
public ICollection<ReportLocationInfo> GetAllReportsInstalled()
{
return _Reports;
}
I am calling it through reflection dynamically:
Program B
internal ICollection<Object> Scan(string path)
{
MethodInfo GetReports =
_reportFactoryType.GetMethod("GetAllReportsInstalled");
ret...
I have a class called Product in my Business object and in another class i want to return a list of objects of this class.Which approach i should use ?
public static List<Product> GetProductList() { .... }
or create another class in my Business object namspace called ProductList which extends List <Products> as follows:
public class...
The dynamic keyword in C# 4 introduces new ways to work with objects that weren't previously possible. How does this overlap with generics? Specifically, are there operations that would be potentially useful which are now legal and valid?
For example, this isn't possible now:
// Use a type whose value is known only at runtime.
Type t =...
Afternoon all,
a little help if you please. In order to circumvent the 2Gb object limit in .NET I have made a class that allocates memory on the heap and this allows me to create arrays up to the limit of my free RAM. However, for ease of development (as it was a proof of concept) it was hard coded for longs. Now that it works I've been...
I have an interface to describe when a class can create a "next" version of itself:
public interface Prototypeable<Type extends Prototypeable<Type>> {
public Type basePrototype(); // the zeroth raw instance of Type
public Type nextPrototype(); // the next instance of Type
}
to be used with
public class Prototyper {
public static <...
I struggle a little with the understanding of generics and how they can and can not be used.
I have a generic class TControlMediator like this:
TControlMediator<C, T> = class
private
FMediatedComponent: C;
public
constructor Create(ComponentToMediate: C);
function GetValue: T; virtual; abstract;
procedure SetValue(Value: T); v...
How can I use a List as a parameter on a method, I try this syntax :
void Export(List<T> data, params string[] parameters){
}
I got compilation error :
Error 34 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?) D:\Resocentro\Proyectos\SRA\SRA.Data\Model\ETLPackague\IET...
In the following class:
public class Example<T> where T : IComparable {
private T _min;
private T _max;
public Example() {
// _min = T.MinValue;
// _max = T.MaxValue;
}
public Example(T min, T max) {
_min = min;
_max = max;
}
public bool Contains(T val) {
return (val...
Hi everyone!!
I'm working in a ASP.NET MVC project and I have this particular situation: I have 3 pages - Product, Order, User. And in each of these pages I have a link calling the same ActionResult differing only by the argument passed depending on the page I'm in. For example:
public ActionResult(string typeOfPage)
{
if (typeOfPag...
I have an old EJB (2.1) project that uses xdoclet (1.2.3) to generate the EJB interfaces. Unfortunately xdoclet makes it impossible to use generics in the method signatures.
Is there a substitute or other way to to allow generics in the parameters?
Here is the minimum type of generics use I'm looking for:
public Object ejbMethod(Coll...
Is there a way to do with stored procedures what you can do with GetTable?
For example, you can do:
var results = GetTable<Client>().Where() // etc
Can we do that with Sprocs?
I'm trying to avoid the terrible result of using code generation to have strongly typed sproc names. This doesn't adhere very well to persistence patterns no...
I've created a class like
TMyClass = class(TObject)
private
FList1: TObjectList<List1>;
FList2: TObjectList<List2>;
public
end;
Now, I want a method FillArray(Content);, which preferably should be implemented once, i.e. no overload. I believe this is possible using generics, but I'm too inexperienced with these beasts to actually ...
AssemblyInstaller.Install expects a System.Collections.IDictionary.
Am I right to be 'allergic' to using non-generic collections such as Hashtable or should I get over myself?!
e.g.
using System.Collections.Generic;
using System.Configuration.Install;
using System.Reflection;
using AssemblyWithInstaller;
namespace InstallerDemo
{
...
I need to write a generic class where the type parameter must be something implementing ICollection<T>. Inside of MyClass I need the collection's item type (in the code snippet marked as ???).
class MyClass<TCollection> where TCollection : ICollection<???>
{
// ...
public void store(??? obj) { /* put obj into collection */ }
// ...
Hi. This code not compiles, because of 'A' expression. It's interesting thing: in A expression expected List<Foo> generic type, but got List<anonymous Foo> (according compiler). Is it a jdk bug or feature?
interface Foo{ void doFoo(); }
public class GenericsTest {
public static<V> List<V> bar(V v){ return new ArrayList<V>();}
...
I have a bas class called Media with two classes that inherit from it, Photo and Video. I am trying to create a collection for the media base class to hold those photo and video objects. So I have created a MediaList class as follows:
public class MediaList: ICollection<Media>
{
private readonly XElement _mediaElement;
public M...
Based on http://alexreg.wordpress.com/2009/05/03/strongly-typed-csv-reader-in-c/, I created a DLL which can read different file types. I also have unit tests that run successfully. I create a struct and use it as the generic type.
Anyway, when I compile, I get a warning on each of the struct fields. For example: field 'FileReader.Tes...