Why ToString() method can be overridden without inheritance being involved in C#?
<p>Please find the below example:</p>

<pre><code>using System;

 class MyClass 
 {
   static int count = 0;
   int id;

   public MyClass() 
   {
     id = count;
     count++;
   }

 public override string ToString() 
 {
   return "MyClass object #" + id;
 }
}

 class Test 
 {
   static void Main() 
   {
     MyClass ob1 = new MyClass();
     MyClass ob2 = new MyClass();
     MyClass ob3 = new MyClass();
     Console.WriteLine(ob1);
     Console.WriteLine(ob2);
     Console.WriteLine(ob3);
   }
 }
</code></pre>

<p>The output from the program is shown here:</p>

<p>MyClass object #0<br>
MyClass object #1<br>
MyClass object #2</p>

<p>As you can see here method ToString() is overridden in the class named 'MyClass' but 'MyClass' is not derived from any class, there exists no inheritance at all. If there is no inheritance involved how 'override' can be used? </p>

<p>If we you change ToString() to any other method Name say 'HelloString()' as in the below Code snippet:</p>

<pre><code> public class Program
 {
    public static void Main(string[] args)
    {            
        MyClass ob1 = new MyClass();
        MyClass ob2 = new MyClass();
        MyClass ob3 = new MyClass();
        Console.WriteLine(ob1);
        Console.WriteLine(ob2);
        Console.WriteLine(ob3);
    }
}

 class MyClass 
 {
   static int count = 0;
   int id;

   public MyClass() 
   {
     id = count;
     count++;
   }

 public override string HelloString() 
 {
   return "MyClass object #" + id;
 }
}
</code></pre>

<p>Compiler throws error: 'no suitable method found to override'</p>

<p>Why this special behavior with 'ToString()' method?</p>