简体   繁体   English

受私人保护不起作用

[英]private protected does not work

I have a method: 我有一个方法:

private protected string SendRequest(BaseRequest request, string httpMethod, bool isPublicRequest) { ... }

BaseRequest is internal, that's why I want to use the new private protected combination. BaseRequest是内部的,这就是为什么我要使用新的受保护的私有组合。

Unfortunately I still get an error: 不幸的是,我仍然得到一个错误:

"Modifier 'protected' cannot be combined with 'private'" “修饰语'受保护'不能与'私人'结合使用”

I upgraded VS to 15.5.2 so why does it not know the new C# Features? 我将VS升级到15.5.2,为什么它不知道新的C#功能? Clean solution didn't help by the way. 顺便提一下,干净的解决方案没有帮助。

This feature requires version 7.2. 此功能需要版本7.2。

to accomplish this: 要做到这一点:

  1. Right-click on your project 右键点击您的项目
  2. at the bottom of the available options click Properties 在可用选项的底部,单击“ Properties
  3. Click on Build 点击Build
  4. Click on Advanced 点击高级
  5. Within the pop-up, change the language version to match the required version (7.2) 在弹出窗口中,更改语言版本以匹配所需的版本(7.2)

Also, as @Sir Rufo has mentioned in the comments section you can set this option for each configuration. 另外,正如@Sir Rufo在评论部分中提到的那样,您可以为每种配置设置此选项。 Therefore changing it for all configurations would be the better option. 因此,为所有配置更改它都是更好的选择。

more info here . 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#是否具有私有和受保护继承的概念? - Does C# have the notion of private and protected inheritance? InternalsVisibleTo与“私人保护” - InternalsVisibleTo with “private protected” 内部且受私有api保护 - Internal and protected in a private api 测试和模拟私有/受保护的方法。 许多帖子但仍然无法使一个例子有效 - Testing and mocking private/protected methods. Many posts but still cannot make one example work 流利的NHibernate自动将私有/受保护的属性映射为Id - Fluent NHibernate automapping a private/protected property as the Id “私人”和“受保护的内部”有什么区别? - What is the difference between “private” and “protected Internal”? 如何确定方法是私有的,受保护的,内部的还是公共的? - How to decide if a method will be private, protected, internal or public? 解密密码短语保护包含私钥的PEM - Decrypt passphrase protected PEM containing private key 辅助功能级别:受保护的和私有的有什么区别 - Accessibility Levels: What is the difference between protected and private 实体框架核心:私有或受保护的导航属性 - Entity Framework Core: private or protected navigation properties
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM