I have static class which contains data, i wish to use static class as datasource in datagridview.
But datasource property only accepts object. How can i set static class as datasource?
You can't. But you could make it a Singleton:
public class MyClass
{
private static MyClass _instance;
public static MyClass Instance
{
get
{
if (_instance == null) { _instance = new MyClass(); }
return _instance;
}
}
private MyClass() { }
}
and then reference it like MyClass.Instance
for the data source.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments