User Tools

Site Tools


everything_object

Everything is an object

In .NET even basic datatypes like string or int are an object.

This means that even these datatypes can (an have) own methods. One method common to every object is AsString() . This method sometimes returns useful data:

local nInt as int
local oDate as DateTime
local lLogic as logic
 
nInt := 1234
oDate := DateTime.Now
lLogic := true
System.Console.WriteLine( nInt:ToString() )
System.Console.WriteLine( oDate:ToString() )
System.Console.WriteLine( lLogic:ToString() )

returns

12345
28.01.2018 17:51:37
true

But sometimes, in more complex classes, the ToString() method returns only the name of the class, and it is to you to define such a method that returns a more meaningful string value.

Regarding the methods of such a class, you should give a look to the System.String class - you will be surprised how many different and useful methods this class already has!

everything_object.txt · Last modified: 2020/06/15 00:55 by joecurran