[英]Is there a way to make Visual Studio generate internal methods instead of public methods by default
By default, Visual Studio generates public methods for C# 默认情况下,Visual Studio为C#生成公共方法
However, I would like my methods to be internal by default. 但是,我希望默认情况下我的方法是内部方法。
Is there a way to change this? 有办法改变吗?
Not possible. 不可能。 It's public by default and not possible to change it. 默认情况下它是公开的,无法更改。
What do you mean? 你什么意思?
In C++ class methods are private by default. 在C ++中,默认情况下,方法是私有的。 In C# class methods are private by default, but struct methods are public by default. 在C#中,默认情况下方法是私有的,但结构方法默认是公共的。
Are either of these cases the one you are concerned about? 您是否担心这两种情况?
Could you be wondering about what symbols are available to things that use a dll you are creating? 您是否想知道使用正在创建的dll的东西可以使用哪些符号?
When you say VS generates public methods, Which feature are you talking about? 当您说VS生成公共方法时,您在说什么功能?
this.notExistingMethod(); this.notExistingMethod();
You will get a Smart Tag(a little Red box) under notExistingMethod (Assuming you have VS 2010). 您将在notExistingMethod下获得一个智能标记(一个红色的小方框)(假设您拥有VS 2010)。 This will help you generate a method with signature "public void notExistingMethod(){}". 这将帮助您生成签名为“ public void notExistingMethod(){}”的方法。
2.You have "Extract Method" for some languages like C#, under refactoring. 2.在重构中,您对某些语言(例如C#)具有“提取方法”。
Both these options by default create private methods or the least required access wil be given in case of Generate form Usage. 默认情况下,这两个选项都将创建私有方法,或者在“生成表单使用情况”的情况下,将给出最少要求的访问权限。
Which type of Method generation are you talking about? 您在谈论哪种类型的方法生成?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.