由于其保护级别而无法访问,而

编程入门 行业动态 更新时间:2024-10-26 17:29:22
本文介绍了由于其保护级别而无法访问,而的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

pls向我发送解决方案 ------>由于其保护级别而无法访问 我声明了sqlconnection sqlcon = new sqlconnection(); sqlcon.connectionstring = configurationManager.AppSettings ["xxx"].Tostring(); 一堂课 和我从另一个创建sqlconnection类的对象的类访问 但是它给出了以上错误..................................>

pls send me solution for ------> is not accessable due to its protection level i declared sqlconnection sqlcon= new sqlconnection(); sqlcon.connectionstring = configurationManager.AppSettings["xxx"].Tostring(); in one class and me accessing from another class creating object of sqlconnection class but it is giving above error .........................>

推荐答案

尝试阅读 C#中的访问修饰符 [点击率]

该代码实际上存在很多错误,但是... 1.使用属性作为变量的访问者,不应在定义变量的范围之外直接访问成员变量 2.使用适当的访问修饰符定义属性,以限制其可访问性.即私有,受保护,内部,公共等. 如果不是Google,希望可以助您一臂之力 c#访问修饰符 [ ^ ]了解更多信息 There''s actually quite a lot wrong with that code, however... 1. Use properties as accessors to variables, you should not be accessing member variables directly outside of the scope in which they''re defined 2. Define the property with the appropriate access modifier to scope it''s accessibility. i.e., private, protected, internal, public etc. Hopefully that''ll get you going, if not Google c# access modifier[^] for more information

更多推荐

由于其保护级别而无法访问,而

本文发布于:2023-11-26 19:58:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634976.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:于其   无法访问   级别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!