Write to a file

Hi, i’ve been working with text files, can anyone tell me if it is possible to write a class like this to a file:

class
{
name: string
last_name : string
number: string
}

And get a .txt file with these fields.

Thanks.