C0312 Compiler Error
Message text
An object reference is required for a nonstatic field, method, or
property.
Explanation
To access a nonstatic variable in a .NET class in a conditional
compilation clause, an instance of the class must be created. This example
uses a simple public class Department that is in the .NET assembly
PBInterop.dll. Department has two member variables: public string Name and
public static int ID. In the following example, the attempt to access the
nonstatic variable Name without creating and using an instance of the
Department class generates C0312:
|
1 2 3 4 5 |
String dept_name #if defined pbwebform then PBInterOp.Department dept dept_name = PBInterOp.Department.Name // C0312 #end if |
This example deploys without error because an instance of the
Department class is created and used to access the nonstatic
variable:
|
1 2 3 4 |
String dept_name dept = create PBInterOp.Department dept_name = dept.Name #end if |
See Also
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments
Oldest