Previous Topic Next topic Print topic


Constants - in COBOL and C# and VB.NET

C# COBOL VB.NET
const int MAX_STUDENTS = 25;

// Can set to a const or var; may be initialized in a constructor
readonly float MIN_DIAMETER = 4.93f; 
class-id Students.

*> optionally public etc., and may reference constants in other classes
01 MAX_STUDENTS binary-long constant value 25 + 3.

*> Can set to a const or var; may be initialized in a constructor
01 MIN_DIAMETER float-short value 4.93 initialize only.

method-id Main().
    display MAX_STUDENTS
    display MIN_DIAMETER
end method.

end class.
Const MAX_STUDENTS As Integer = 25

' Can set to a const or var; may be initialized in a constructor
ReadOnly MIN_DIAMETER As Single = 4.93
Previous Topic Next topic Print topic