C
clara
Hi all,
what is the difference between the late binding and reflection?
clara
what is the difference between the late binding and reflection?
clara
Reflection is the mechanism that allows to get information on a type and
other elements at runtime :
MsgBox(GetType(String).GetMembers.Count)
gets information about the string type...
Late binding is resolving a call at runtime (and in particular calling a
method on an object whose type is not known at all at compile time i.e. on a
"As Object" variable).
Dim obj As Object
obj = CreateObject("WScript.Network")
MsgBox(obj.UserName)
MsGbox(obj.ThisOneIsLikelyNotWorking)
If I change the "WScript.Network" string the first call could work or not
depending on wether or not this class exposes a UserName property but I'll
know it only at runtime...
They are somewhat related (AFAIK for now C# can use Reflection to implement
late binding whihc is not yet available as a language feature as in VB).
Try wikipedia for details :http://en.wikipedia.org/wiki/Reflection_(computer_science)
http://en.wikipedia.org/wiki/Late_bindingbut I preferhttp://en.wikipedia.org/wiki/Dynamic_dispatchthat is IMO closer of how
"Late binding" is used in the context of Visual Basic...
In most cases, you'll want to avoid late binding and at a less degree
System.Reflection as much as you can...
clara said:Hi Patrice,
Thank you very much!
My next question is usage of Reflection and especially how can we combine
Attribute with it?
Clara