Prev | Current Page 100 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"


One last note to consider is that even though the system generates a default, parameterless
initializer, you can??™t call it using the Me keyword.
Finalizers
Value types are not allowed to have a finalizer and are removed from the stack as soon as they
go out of scope. The concept of finalization, or nondeterministic destruction, is reserved for
instances of classes, or objects, because that is how management of the heap works. If structures
had finalizers, the runtime would have to manage the calling of the finalizer each time
the value goes out of scope.
Be careful when initializing resources within structure constructors. Consider a value type
that has a field, which is a handle to some sort of low-level system resource. Suppose this lowlevel
resource is allocated, or acquired, in a special constructor that accepts parameters. You
now have a couple of problems to deal with. Since you cannot create a default, parameterless
constructor, how can you possibly acquire the resource when the user creates an instance of
the value without using one of the custom constructors? The answer is, you cannot. The second
problem is that you have no automatic trigger to clean up and release the resource, since
you have no destructor.
Interfaces
Although it??™s illegal for a structure to derive from another class, it can still implement interfaces.


Pages:
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
dieta light fenomenalne mieszkania do wynajęcia warszawa katalog stron życzenia z okazji urodzin fenster berlin