4
For example:
BindingSource bs = new BindingSource();
bs.DataSource = typeof(object);
Why should I use typeof(object)
instead of just object
or even "object"
?
Edit:
As other people have asked, there’s the code where I first saw the keyword typeof
, and in this case was used with a BindingSource
.
The code has been 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"); //**
}
I don’t think you need to, look at the example here: https://msdn.microsoft.com/pt-br/library/system.windows.forms.bindingsource.datasource(v=vs.110). aspx
– Ricardo