June 2, 2009

Create a Generic List at Run Time

You can create a list of a specific type at run time by passing the type to the MakeGenericType method, for example: Type t = Type.GetType(“System.Int32”);IList tList= (IList)Activator.CreateInstance( (typeof(List&lt&gt).MakeGenericType(t))); tList.GetType().FullName will return the full name of the specified type.

How to Iterate Through All the Properties of a Class

The following code gets all the properties of an Employee class using Reflection. Here’s the Employee class code: class Employee{ private int m_age; private string m_name; public int Age { get { return m_age; } set { m_age = value; } } public string Name { get { return m_name;

Send a Cookie to the Server Using the setRequestProperty Method

The following code snippet is J2SE 6.0 code that uses the setRequestProperty method to send cookies to the server. You can find more information about cookies and the complete application of this example here. try { //optional – for proxy connection used InetAddress addr=InetAddress.getByName(“www-proxy.omv.com”); InetSocketAddress ISA=new InetSocketAddress(addr,8080); java.net.Proxy proxy=new java.net.Proxy(java.net.Proxy.Type.HTTP,ISA);

Quickly Find All “TODO’s” in Your .NET Project

It is normal practice for developers to include “TODO” comments for fellow developers and themselves. Developers also spend a lot of time searching for them later. In Visual Studio (VS), a quick way to retrieve a list of all the TODO’s in a project is to go to View ?

Bricks and Mortar: Building a Castle

n an application built with object-oriented techniques, objects are the bricks. You construct little pieces of code encapsulated in these bricks. To build bigger structures, you need to hold these bricks together. You can hardwire them together by instantiating dependent objects within your objects, but it makes the whole structure