How to save this content in text file? in C#
using System;
using System.Collections.Generic;
using System.Text;
namespace LinkList
{
class Program
{
static void Main(string[] args)
{
list x = null;
list first;
Random rnd = new Random();
x = new list();
first = x;
x.data = rnd.Next(20, 500);
x.next = null;
for (int i = 0; i < 20; i++)
{
x.next = new list(); //create new node
x = x.next;
x.next = null;
//x.data = System.Convert.ToInt32(Console.ReadLine());
x.data = rnd.Next(20, 500);
}
x = first;
int count = 0;
int y;
while (x != null)
{
Console.WriteLine(x.data);
x = x.next;
}
}
}
class list
{
public int data; //4 byte
public list next; // 4 byte
}
}