using System;
using System.ComponentModel;
public class Convertors
{
/// <summary>
/// See Convert.ChangeType.
/// </summary>
/// <typeparam name="T">New type, may be Nullable.</typeparam>
/// <param name="value">Object</param>
/// <returns>Typed object.</returns>
public static T ChangeType<T>(object value)
{
Type conversionType = typeof(T);
if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value == null)
{
return default(T);
}
else
{
NullableConverter nullableConverter = new NullableConverter(conversionType);
conversionType = nullableConverter.UnderlyingType;
}
}
return (T)Convert.ChangeType(value, conversionType);
}
}
Reflection
The full name of the Array type
using System;
class TestFullName
{
public static void Main() {
Type t = typeof(Array);
Console.WriteLine("The full name of the Array type is {0}.", t.FullName);
}
}
Get Derivation from an object
[/csharp][/csharp][/csharp][/csharp][/csharp]
Get all methods from an object
[/csharp][/csharp][/csharp][/csharp][/csharp]
Makes a shallow copy of the object
[/csharp][/csharp][/csharp][/csharp][/csharp]
Makes a shallow copy of the object to a different class type (inherits from the original)
[/csharp][/csharp][/csharp][/csharp][/csharp]
Determining the base classes and interfaces for a class.
[/csharp][/csharp][/csharp][/csharp][/csharp]