generic-type-argument Questions

3

Solved

I get the following error despite it's exactly one used in examples: error: type List does not take parameters List<String> strings_wat = new ArrayList<String>(); Java is version...
Pricefixing asked 9/4, 2014 at 7:25

3

Solved

I need to use the following generic class and method ParseFrom() in it: public sealed class MessageParser<T> : MessageParser where T : IMessage<T> { public MessageParser(Func<T> ...
Fasten asked 19/8, 2021 at 14:46

4

Solved

As an exercise I'm trying to implement Python's str.join method in C++. I will eventually add the function as a method of the std::string class but I figure getting it to work is more of a priority...
Typal asked 17/11, 2016 at 6:1

1

Solved

I want to read a line from input and convert it to generic type. something like fun <T> R() : T { return readLine()!!.toType(T) } so for R<int>() it will call toInt() for long toLong()...

2

Solved

I've recently come across this unusual (to me) Java syntax...here's an example of it: List list = new <String, Long>ArrayList(); Notice the positioning of the <String, Long> type arg...
Hexameter asked 25/3, 2019 at 2:55

2

Solved

I have the following simple program that defines 2 identical upper bounds for type parameter and abstract type alias respectively: package scala.spike.typeBoundInference object Example1 { trait ...

1

Solved

Given the following class: public static class EnumHelper { //Overload 1 public static List<string> GetStrings<TEnum>(TEnum value) { return EnumHelper<TEnum>.GetStrings(value...
Trefoil asked 18/5, 2018 at 6:23

1

Solved

ReSharper has a suite of code annotations which are useful for explicitly expressing code intent that can be used by the IDE. Two of the most useful annotations are the [CanBeNull] and [NotNull] at...
Collectivize asked 23/3, 2018 at 16:11

3

Solved

The following code snippet throw me the error as shown in the header, I didn't figure out why it does not work as T is of type Number, I expected operator '+' to be fine. class MathOperatio...
Howrah asked 17/7, 2017 at 20:53

2

Solved

I have a bunch of regular, closed and opened types in my assembly. I have a query that I'm trying to rule out the open types from it class Foo { } // a regular type class Bar<T, U> { } // an...
Syrup asked 12/9, 2014 at 15:14

3

Solved

I wants to achieve something like this in java, but getting compile time error: The method onMessage(TextMessage, Class) in the type AbstractTestLoader is not applicable for the arguments (Tex...
Aboveboard asked 24/3, 2017 at 4:13

1

Solved

As I know, one of the main purposes of generics in Java is providing compile-time type safety. If it gets compiled, the code will run without issues. Then why is the following code being com...
Candlestick asked 3/9, 2016 at 10:11

4

Solved

I'm attempting to create various extension method for a generic type bound to specific generic type parameters in F#, but the language does not seem to be allowing me: What I want to do is somethi...

4

Solved

Just when I thought I finally understood generics, I came across the following example: public class Organic<E> { void react(E e) { } static void main(String[] args) { //1: Organic<? ...
Owen asked 30/10, 2012 at 6:22

1

Solved

I tried that: sealed trait AorB trait A extends AorB { def apiA:... } trait B extends AorB { def apiB:... } and in another file: trait C[AB<:AorB] extends AB But get an error: class type r...
Madalene asked 17/3, 2016 at 16:21

3

Solved

Please check the following codes segments: public interface ICountable { } public class Counter<T> where T : ICountable { public int Count(IEnumerable<T> items) { return 0; } pu...
Bean asked 16/12, 2015 at 10:44

2

Solved

Here's a simple example that demonstrates a type-erasure-related issue I am running into. I have a class like this: public abstract class AbstractHandler<T> { ... public abstract Class&lt...
Fulllength asked 15/4, 2015 at 20:58

1

Solved

I suspect the short answer to this question is "no" but I'm interested in the ability to detect the use of the dynamic keyword at runtime in C# 4.0, specifically as a generic type parameter for a m...
Turpin asked 4/10, 2013 at 11:37

3

Solved

I have the following classes public class A<T> { } public class B<T> : A<T> { } public class C1 : B<string> { } public class C2 : B<int> { } What I would like to do, ...
Dettmer asked 19/9, 2012 at 12:38

2

Solved

Background info: I'm currently trying to set up a generic graph library that includes a few different search algorithms (I've started with Dijkstra's). I've set up a few traits to represent methods...
Retentive asked 30/7, 2011 at 5:56

3

Solved

HI, I have a requirement to create instance for list object at runtime using reflection. For example I have 2 classes like below, class Class1 { List<Class2> class2List; public List<Cla...
Anglofrench asked 6/5, 2011 at 9:5

5

Solved

I basically have something like this: void Foo(Type ty) { var result = serializer.Deserialize<ty>(inputContent); } Foo(typeof(Person)); The Deserialize<ty> doesn't work because it ...
Prefecture asked 13/5, 2009 at 8:0

2

Solved

If I have the following code: MyType<int> anInstance = new MyType<int>(); Type type = anInstance.GetType(); How can I find out which type argument(s) "anInstance" was instant...
Gablet asked 16/11, 2008 at 14:8
1

© 2022 - 2024 — McMap. All rights reserved.