Access a static property of a generic class?

.net, generics

Solution

You'd have to put some generic type parameter in there. That being said, I'll sometimes use some kind of inheritance scheme to get this functionality without having to put in the generic type parameter.

public class Foo
{
    public static int FoosHeight;
}

public class Foo<T> : Foo
{
   // whatever
}

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Foo.FoosHeight = 50; // DO I Set "object" here?
    }
}

That being said, this will keep the same FoosHeight regardless of the generic type parameter passed into `Foo<T>`. If you want a different value for each version of `Foo<T>`, you'll have to pick a type to put in that type parameter, and forget the inheritance scheme.

Problem

I use a `Height` for all the `Foo`s members. Like this ``` public class Foo<T> { public static int FoosHeight; } public partial class Form1 : Form { public Form1() { InitializeComponent(); Foo<???>.FoosHeight = 50; // DO I Set "object" here? } } ``` The same situation is in VB.NET.

Original source