I have this generic list and I want to get the byte size of the type like if T is string or int etc., I tried both ways as written in getByteSize(), and just to let you know I am using only one way at a time ...
but when I try to compile, it gives an error saying "Error: The type or namespace name 'typeParameterType' could not be found (are you missing a using directive or an assembly reference?)"
public class iList<T> : List<T>
{
public int getByteSize ()
{
// way 1
Type typeParameterType = typeof(T);
return sizeof(typeParameterType);
// way 2
Type typeParameterType = this.GetType().GetGenericArguments()[0];
return sizeof(typeParameterType);
}
}
And idea what I am doing wrong here?