locked
Method Extension RRS feed

  • Question

  • Hi

    Is there any way to create a custom method of the Console class?

    I am creating a method as

    public static void show(this Console c)

    {

    Somestatement;

    }

    but the Console class is not able to access this method.


    Shivi Gupta

    Monday, October 29, 2012 6:20 AM

Answers

  • hi,

    As far i know, it is not possible because 'Console' is a static class and to access an extension method you need an instance of a class.

    Regards,

    Vinil;

    • Proposed as answer by Jason Dot Wang Wednesday, October 31, 2012 7:59 AM
    • Marked as answer by Jason Dot Wang Tuesday, November 6, 2012 6:07 AM
    Monday, October 29, 2012 6:28 AM