What is early binding and late binding

Answer Posted / prasad sethuramalingam

BINDING :A process when an object is assigned to an object
variable.
EARLY BINDING:
An object is early bound when it is assigned to a variable
declared to be of that specific object type. Early bound
objects allow the compiler to allocate memory and perform
other optimizations before an application executes. For
example, the following code fragment declares a variable to
be of type FileStream:
' Create a variable to hold a new object.
Dim FS As System.IO.FileStream
' Assign a new object to the variable.
FS = New System.IO.FileStream("C:\tmp.txt", _
System.IO.FileMode.Open)
LATE BINDING:
By contrast, an object is late bound when it is assigned to
a variable declared to be of type Object. Objects of this
type can hold references to any object, but lack many of the
advantages of early-bound objects. For example, the
following code fragment declares an object variable to hold
an object returned by the CreateObject function:

' To use this example, you must have Microsoft Excel
installed on your computer.
' Compile with Option Strict Off to allow late binding.
Sub TestLateBinding()
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
xlApp = CreateObject("Excel.Application")
' Late bind an instance of an Excel workbook.
xlBook = xlApp.Workbooks.Add
' Late bind an instance of an Excel worksheet.
xlSheet = xlBook.Worksheets(1)
xlSheet.Activate()
' Show the application.
xlSheet.Application.Visible = True
' Place some text in the second row of the sheet.
xlSheet.Cells(2, 2) = "This is column B row 2"
End Sub
I took this from this URL:
http://msdn.microsoft.com/en-us/library/0tcf61s1(VS.80).aspx

Is This Answer Correct ?    38 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

You are creating a custom usercontrol, some of the newly created properties are shown in the properties window. How you can hide a new property named theme from the properties window?

505


What is int32 maxvalue?

516


What are reflections in c#?

489


explain the three services model commonly know as a three-tier application.

550


What is overloading with example?

503






How do you read an Excel sheet in C#?

560


What Is The Smallest Unit Of Execution In .net?

528


Can fields inside a class be virtual?

541


What does the parsefloat function do?

493


Why are dynamic link library used over static one?

546


How does bitwise xor work?

471


What is thread pooling?

536


What is lazy loading and eager loading in c#?

486


Explain about c# language.

603


Define delegate in c#?

550