关于c#.net上的访问修饰符 [英] regarding c#.net on access modifiers

查看:65
本文介绍了关于c#.net上的访问修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是.net的新手,我怀疑在事件生成时单击按钮是正确的吗?我们正在该事件下编写代码,但我的doudt而不是protected关键字,我可以将public或protected interal设置为有可能写
请告诉我

hi i am new for .net i have one doubt when a button is clicked under an event is generate right?we are writing the code under that event but my doudt is instead of protected keyword can i put public or protected interal is there any possible to write
please tell me

推荐答案

是的-如果需要,您可以更改访问修饰符.

但是,您可能应该-使其更加公开可用通常不是一个好主意,因为它可以修复表单的设计.一旦可以在外部使用它,就必须假定它不容易更改.
而是让它调用具有所需访问权限的方法,并让外界也使用该方法.
Yes - you can change the access modifier if you need to.

However, you probably shoudln''t - making it more publicly available is not normally a good idea, as it can fix the design of your form. Once it is possible that it has been used externally, you have to assume that it can''t easily be changed.
Instead, have it call a method with the required access, and let the outside world use that as well.


这篇关于关于c#.net上的访问修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆