Is there a way to restrict access to a public method to only a specific class in C#?

后端 未结 5 1463
萌比男神i
萌比男神i 2021-01-12 06:30

I have a class A with a public method in C#. I want to allow access to this method to only class B. Is this possible?

UPDATE:

This is what i

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 07:02

    Place both classes in a separate assembly and make the method internal.

提交回复
热议问题