ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / OOP (Object Oriented Programming)
  • Overview
  • Syntax
  • Declaring a dynamic object
  • Instantiating a dynamic object
  • Freeing a dynamic object
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Dynamic instantiation of a .NET object
Overview
A .NET object can be dynamically associated with a .NET class, we talk of dynamic instantiation of object.
Instantiating a dynamic .NET object allows you to create an object at a given time and to free this object when it is no longer used.
To instantiate a .NET object, you must:
  1. declare a dynamic .NET object
  2. instantiate the .NET object
Remark: The object is automatically freed at the end of the application when it is no longer used. However, you can force the object destruction (to trigger the destructor execution for example).
Syntax

Declaring a dynamic object

<Object Name> is [object] <Class Name> dynamic
Details of syntax
<Object Name>
Name used to identify the instance of the .NET class.
<Class Name>
Name identifying the class. If the .NET class is named like a WLanguage keyword, the name of the class must be enclosed in quotes (for example, o is "<Class>"(<Parameters>).

Instantiating a dynamic object

<Object Name> = new <Class Name>([<Parameters>])
Details of syntax
<Object Name>
Name used to identify the instance of the .NET class.
<Class Name>
Name identifying the class. If the .NET class is named like a WLanguage keyword, the name of the class must be enclosed in quotes (for example, o is "<Class>"(<Parameters>).
<Parameters>
Optional parameters of constructor.

Freeing a dynamic object

delete <Object Name>
Details of syntax
<Object Name>
Name that identifies the instance of the class.
Remarks:
  • The object is automatically freed at the end of the application when it is no longer used. However, you can force the object destruction (to trigger the destructor execution for example).
  • To check whether a dynamic object is allocated and whether it was not freed yet, this object must be compared to NULL. Example:
    IF <Object Name> = NULL THEN ...

    IF <Object Name> <> NULL THEN...
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help