Hello,
I have the following method in C#:
public T Read<T>()
{
T[] t = new T[1];
int s = Marshal.SizeOf(typeof(T));
if (index + s > size)
throw new Exception("Error 101 Celebrity");
GCHandle handle = GCHandle.Alloc(t, GCHandleType.Pinned);
Marshal.Copy(dataRead, index, handl...
Ok, I poked around before posting and can't seem to find anything... so here we go.
I decided that returning datasets, working with datasets and datatables in a front end app is a rather bad idea. So with the magic of generics I am returning a generic list via Webservice call ( not WCF just plain ol' asmx ) . That works dandy as long as...
Possible Duplicate:
What are the reasons why Map.get(Object key) is not (fully) generic
According to the javadocs (http://java.sun.com/javase/6/docs/api/java/util/Map.html) for the Map interface, the definition of get is
V get(Object key)
Returns the value to which the specified key is mapped, or null
if this ...
I am working through a bug. In recreating the bug for the following sample I was able to determine why the problem is happening. But I am stuck for a better solution. So given the following program:
public interface IFoo<T> {
T OutputType(T param);
}
class Foo : IFoo<Foo> {
public virtual Foo OutputType(Foo param) {
Con...
I am wondering whether I can upgrade a basic IoC container I am using to support lazy load.
So if I have registered IFoo, I would like the IoC container to know how to fulfil both of the following dependencies (the first being the standard way IoC containers work, while the second returns a simple delegate that calls into the container f...
hey guys, I've removed some of the complexities of my needs to the core of what I need to know.
I want to send a collection of Values to a method, and inside that method I want to test the Value against, say, a property of an Entity. The property will always be of the same Type as the Value.
I also want to test if the value is null, or...
Hi,
I have created a Generic Extension method for DataRow object. The method takes no argument. I want to Invoke the Generic method through Reflection using MethodInfo. I can do this for Normarl public methods, but somehow I cannot get the reference of the Generic Extension method.
I've read this question on SO which somehwat relates t...
I have asked this question about using the a Linq method that returns one object (First, Min, Max, etc) from of a generic collection.
I now want to be able to use linq's Except() method and I am not sure how to do it. Perhaps the answer is just in front on me but think I need help.
I have a generic method that fills in missing dates fo...
I am looking for a way to store a key-value pair in the application settings. From what I have found, key-value pair dictionaries are not serializable, and therefore cannot be stored in the application settings.
Currently I have tried all sorts of dictionaries and collections and all of them work, until I restart the application, then a...
I have a piece of code that I think should compile, but it doesn't. Here is the code:
public class Program {
public void myMethod(List<EnumMap<? extends MyInterface, String>> map)
{
}
public void caller()
{
EnumMap<MyEnum, String> map = new EnumMap<MyEnum, String>(MyEnum.class);
List<EnumMap<MyEnum, String>> list = new LinkedList<E...
I have the following implicit conversion for java.util.Enumerations
implicit def enumerationIterator[A](e : Enumeration[A]) : Iterator[A] = {
new Iterator[A] {
def hasNext = e.hasMoreElements
def next = e.nextElement
def remove = throw new UnsupportedOperationException()
}
}
Unfortunately it doe...
Is there any good way to create a generic Vector4 class in C#?
I have a couple of units(force, distance, moment, rotation, acceleration, velocity etc) that all need a 3d-representation and they all behave very similar and should therefore support the basic functions for adding, multiplying etc.
Each class also contain some special case...
What meaning has <E> on the code Collection<E>?
...
I have backed myself into a a bit of a corner. Here is a simplified version of what I have (in C#):
class OuterClass
{
private class BadClass
{
private int Data;
public BadClass()
{
Data = 0;
...
}
}
T Build<T>(Object Input)
{
T x = new T();
...
This code snippet is from C# in Depth
static bool AreReferencesEqual<T>(T first, T second)
where T : class
{
return first == second;
}
static void Main()
{
string name = "Jon";
string intro1 = "My name is " + name;
string intro2 = "My name is " + name;
Console.WriteLin...
Hi,
I'm trying to write a generic class which contains a generic TObjectList< T > which should contain only Elements of TItem.
uses
Generics.Collections;
type
TItem = class
end;
TGenericClass<T: TItem> = class
public
SimpleList: TList<T>; // This compiles
ObjectList: TObjectList<T>; // This doesn't compile: Compiler...
I've been trying to make a generic class to represent a range of values but am having some difficulty trying to work out what I'm missing (the compiler comlplains about a missing copy constructor, but all the implementations I've tried have failed). So my questions:
Is there a Range template somewhere I've missed to avoid me reinventin...
Is there a tool that would allow me to check use of generic collections in code that must be compilable with Java 1.4? I would imagine example code as:
Map/*<String, Integer>*/ map = new HashMap();
map.put("abc", new Integer(3)); // ok
map.put("def", "ghi"); // warning
EDIT: Unfortunately the build process is "set in stone" to use J...
Hi!
Is there a way to declare that the variable type of a generic class must be serializable?
Best RegardsOliver Hanappi
...
I have come across some forum postings suggesting that the usage of generics in Ext-GWT is flawed. The postings are:
http://extjs.com/forum/showthread.php?t=40759
http://stackoverflow.com/questions/523728/why-isnt-google-web-toolkit-more-popular
With the latest release of ExtGWT, do these flaws still hold good?
...