本文介绍了由于其保护级别而无法访问,而的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
更多推荐
由于其保护级别而无法访问,而
发布评论