locked
Is there a way to hide a public method in a WinRT Component?

    Question

  • I need to have a public method on a WinRT Component, because its called by an external static function. However, I'd like to hide the method so that it cannot be called by users of the WinRT Component. Is there some meta annotation I can use?
    Wednesday, July 16, 2014 7:57 AM

Answers

  • but you can still use internal:

    public ref class Class1 sealed
        {
        public:
            Class1();
    
    	internal:
    		void DoSomething();
        };

    but then you can't call this method outside the dll; so other projects cant use this method. Only inside the project you can call this method.


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, July 16, 2014 9:59 AM

All replies

  • cant you make it internal?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, July 16, 2014 8:42 AM
  • No, I cannot make it private. Then the static non-member function cannot access it anymore.
    Wednesday, July 16, 2014 9:00 AM
  • i didnt said to make it private but internal. internal means all code inside the same assembly can access it but not from outside the assembly

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, July 16, 2014 9:47 AM
  • We are talking about c++ here, right? Whats an assembly?
    Wednesday, July 16, 2014 9:51 AM
  • sorry my bad! i thought we were doing C#

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, July 16, 2014 9:56 AM
  • but you can still use internal:

    public ref class Class1 sealed
        {
        public:
            Class1();
    
    	internal:
    		void DoSomething();
        };

    but then you can't call this method outside the dll; so other projects cant use this method. Only inside the project you can call this method.


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, July 16, 2014 9:59 AM
  • Cool. Is that a C++/CX Extension? Didn't know about that.

    Thanks! That's what I want... the method is now invisible for users of the component.

    Wednesday, July 16, 2014 10:08 AM