469,609 Members | 1,082 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Manged Code Issues??

al
Hi,

I'm very confused about the following:
Can someone please explain the difference between Type and Strong
Typed Data and if there is untyped data in the Managed Code, and how
this relates to earyl and latte bindings? Also, what is the
defference between close and dispose and how they relate to Finalize
argument?

MTIA,
Grawsha
Nov 20 '05 #1
1 834
"al" <gr*********@yahoo.com> wrote in message
news:66**************************@posting.google.c om...
Hi,

I'm very confused about the following:
Can someone please explain the difference between Type and Strong
Typed Data
Type = data type, whether it's a primative type, value type, structure, or
reference type (class).
The data isn't necessarily strongly typed. The code is strongly typed.
Strongly typed code avoids implicit data type conversion and requires type
definition for all variables/references.
and if there is untyped data in the Managed Code,
All data is typed, however if what you mean is a loose generic type (like
Variant from VB6) then you can use the "object" type.
Some .NET languages allow you to compile code that isn't strongly typed,
others don't.
and how
this relates to earyl and latte bindings?
Early binding occurs when the compiler knows the interface ahead of time.
Late binding occurs when the compiler has no idea about the interface ahead
of time.

If I write
Dim X As MyClass
X = New MyClass

then call a method using that reference, like
X.GetTotalRevenue(Months.January)

the compiler knows that the GetTotalRevenue method exists on the MyClass
interface, and can call the code directly. This is early binding. However,
if I write this instead:
Dim X As Object
X = New MyClass

then call the same method:
X.GetTotalRevenue(Months.January)
the compiler has no idea that the "object" instance will have a
GetTotalRevenue method when this code runs. It has to inspect the object and
make sure that the object supports the method AND supports a method that has
the right number and type of parameters provided (or can be converted to
such), then invokes the method by using reflection. This is late binding,
and it is significantly slower.
Also, what is the
defference between close and dispose and how they relate to Finalize
argument?
If it sounds like it makes sense to have a Close method on a class (like it
makes sense to close a Stream or a Connection), then you typically code a
Close method. It basically does the same thing as Dispose in most cases.
Finalize is called when the Garbage Collector is about to wipe out the
object data from memory. It is the last chance for the object to see if it
hasn't be properly disposed, and call the clean-up code if needed. If a
class supports Dispose or Close, and Dispose or Close was already called,
then Finalize should ignore the clean-up. Managed data doesn't need to be
manually cleaned up, but if managed code is using unmanaged data internally
(like various window API handles), then the class using these unmanaged
resource must provide a Dispose/Close method, and must do a final check for
clean-up of these unmanaged resources in Finalize.

-Rob Teixeira [MVP]
MTIA,
Grawsha

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.