For example:
BindingSource bs = new BindingSource();
bs.DataSource = typeof(object);
For what reason should I use typeof(object)
instead of just object
or even "object"
?
edit:
As others have asked, here is the code where I first saw the use of the typeof
keyword, and in that case it was used with BindingSource
.
The code was found here , and yes, the code works.
BindingSource bs = new BindingSource(); //**
private void Form1_Load(object sender, EventArgs e)
{
bs.DataSource = typeof(Airplane); //**
bs.Add(new Airplane("Boeing 747", 800));
bs.Add(new Airplane("Airbus A380", 1023));
bs.Add(new Airplane("Cessna 162", 67));
grid.DataSource = bs; //**
grid.AutoGenerateColumns = true; // create columns automatically //**
txtModel.DataBindings.Add("Text", bs, "Model"); //**
}