Override ToString() function in your own class

Sourav.Kayal
Posted by Sourav.Kayal under C# category on | Points: 40 | Views : 899
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Data.SqlClient;
namespace BlogProject
{
public class MyClass
{
public override string ToString()
{
return "I am override ToString function";
}
}
class Program
{
static void Main(string[] args)
{
MyClass c = new MyClass();
Console.WriteLine(c.ToString());
Console.ReadLine();
}
}
}

Comments or Responses

Login to post response