Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to add an extension method for console class named "WriteLog". i tried like this


C#
using System;
namespace MyName
{
  static class MyName
  {
     public static void WriteLog(this Console c)
     {
        Console.WriteLine("Hello");
     }
  }
}


now i am using this by namespace but its not showing in console class...

pls tell me where i am wrong.........
Posted

1 solution

Console is a static class. You can not add extension method to a static class.
 
Share this answer
 
Comments
Anjanee Kumar Singh 31-May-13 2:29am    
ok sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900