Click here to Skip to main content
15,304,276 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
iv'e got a object witch i create out of an entity(T) using reflection , the object is my implementation of a table it holds a List of Columns witch i extract their properties from the entity using reflection :
public class Generic_Table<T> : Table

    ...// in ctor
    type = this.GetType().GetGenericArguments()[0]; // type of T

    private void BuildColumns(Type type)
        PropertyInfo[] properties = type.GetProperties();

        Columns = new KeyValuePair<string, Type>[properties.Count()];
        int i = 0;
        foreach (PropertyInfo property in properties)
            Columns[i++] = new KeyValuePair<string, Type>(property.Name, property.PropertyType);


i'm looking for a way to cast the PropertyType value as a nullable type

so that the Type value in Columns[i] would be int? if for example some property as an int
PropertyType value.
eranotz50 16-Jul-11 9:58am
back to the issue at hand iv'e tried using property.PropertyType.MakeByRefType() this makes The Type to be int& witch causes a different problem when i try to use this Type in generic methods this throws an Argument Exception The type 'System.Int32&' may not be used as a type argument

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900