Home > .net 3.5, c#, Visual Studio 2008 > .NET 3.5 New Features with IVKM libraries

.NET 3.5 New Features with IVKM libraries

October 24, 2007

A reader emailed asking if you were locked down in functionality when using libraries created by IKVM.  Here’s a quick sample of of the Employee object I created in Eclipse earlier. 

I used the object in a generic list, added Employee objects to the list using the new .NET 3.5 object initializers. 

List<Employee> employeeList = new List<Employee>();


employeeList.Add(new Employee


Name = “David Longnecker”,

Salary = 1250000F,

Email = “davidl@email.com”



employeeList.Add(new Employee


Name = “Some Employee”,

Salary = 50000F,

Email = “someone@email.com”


employeeList.Add(new Employee


Name = “Another Employee”,

Salary = 21000F,

Email = “another@email.com”



foreach (Employee emp in employeeList)


Response.Write(emp.toString() + “<br/>”);


This provides us with exactly what we’d expect:

David Longnecker, davidl@email.com, $1250000.0
Some Employee, someone@email.com, $50000.0
Another Employee, another@email.com, $21000.0

What about some Lambdas?

var david = employeeList.Where(emp => emp.Name.ToLower().StartsWith(“david”));


Response.Write(String.Format(“I found {0} employees named David.<br/>”,


Hopefully there’s just one of me—it’d be scary if there were more.

I found 1 employees named David.


Now, one final check—using a custom created Extension method (the ToJson method) to retrieve the Json string from our Java object.

string employeeJson = employeeList.ToJson();


Response.Write(employeeJson + “<br/>”);

[{“Name”:”David Longnecker”,”Email”:”davidl@email.com”,”Salary”:1250000},{“Name”:”Some Employee”,”Email”:”someone@email.com”,”Salary”:50000},{“Name”:”Another Employee”,”Email”:”another@email.com”,”Salary”:21000}]

Looks good and sure beats the pain of creating JSON in Java!

So, from what I’ve dinked with so far—yes, classes and methods that you translate from Java to .Net seem to take full advantage of the .NET 3.5 features—without much additional overhead.

%d bloggers like this: