Showing posts with label generics. Show all posts
Showing posts with label generics. Show all posts

Friday, June 8, 2012

Why does C# forbid generic attribute types?


This causes a compile-time exception:




public sealed class ValidatesAttribute<T> : Attribute
{

}

[Validates<string>]
public static class StringValidation
{

}

Tuesday, June 5, 2012

C# List<> OrderBy Alphabetical Order


I'm using C# on Framework 3.5. I'm looking to quickly sort a Generic List<>. For the sake of this example lets say I have a List of a Person type with a property of lastname. How would I sort this List using a lambda expression?

Monday, May 21, 2012

Java Enum definition


I thought I understood Java generics pretty well, but then I came across the following in java.lang

Wednesday, May 16, 2012

Generics using Enum in Java


I have an enum




public enum Days {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY

Wednesday, April 25, 2012

Get generic type of java.util.List


I have;




List<String> stringList = new ArrayList<String>();
List<Integer> integerList = new ArrayList<Integer>();

Monday, April 16, 2012

Is it possible for Scala to have reified generics without changing the JVM?


I've recently started learning Scala and was disappointed (but not surprised) that their generics are also implemented via type erasure.

Friday, February 24, 2012

Tuesday, February 21, 2012

Instantiate a type based on json and metadata using lift-json


I would like to deserialise Scala case classes that have been serialised using lift-json. The problem I am having is, I don't know how to invoke the generic method extractOpt[A] method below: