Date parsed: 08/10/2007 10:22:14
Date: Mon, 8 Oct 2007 09:22:14 +0100
<rn5a@rediffmail.com> wrote in message
news:1191812973.476057.37770@o3g2000hsb.googlegroups.com...
> I learnt the term "late binding" from a book which I am using to learn
> ASP.NET. As stated in the book (& as stated in my previous post), late
> binding means variables of type "Object" are not processed until
> runtime but then variables of other data types are also not processed
> until runtime i.e. until the app is run. Variables, let them be of any
> data type, will be processed only when the app is being run (obviuosly
> never at design time). So why does the book specifically mention that
> *variables of "Object" data type are not processed until runtime*?
See below...
> Also, if I am not wrong, it can be concluded from the statement given
> in the book that variables of data types other than the "Object" data
> type are bound early (early binding) Irrespective of whether
> variables are bound early or late, the binding takes place during
> runtime. So does late binding mean variables of "Object" data type are
> processed only AFTER variables of all other data types have been
> processed? If not, then what's the difference between late binding &
> early binding?
Early binding and late binding were important before .NET, but are largely
irrelevant now...
Early binding means defining a variable of a specific type because you know
at design-time what type of variable you need...
DataSet MyDataSet = new DataSet();
Late binding means defining a variable of a non-specific type (usually an
Object variable) because all you know at design-time is that you will need a
variable of one sort or another, but can't know what *specific* type until
runtime...
object MyDataObject = null; // design-time
protected void Page_Load(object sender, EventArgs e) // runtime
{
if (SomeCondition)
{
MyDataObject = new DataSet();
}
else
{
MyDataObject = new SqlDataReader();
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net