[英]I want to put a comment that will let me get to a different block of code in c#
I think I could maybe use cref in the xml comments.我想我可以在 xml 注释中使用 cref。
I also found a devious way using the nameof operator.我还发现了一种使用 nameof 运算符的狡猾方法。
string fakeString = nameof( NewForm.HandleCommandLineArgments ); // use go to definition to get to NewForm.HandleCommandLineArgments
Any other ideas?还有其他想法吗?
Update: I realize how to go to definition, ideally I wouldn't have to add "string fakeString".更新:我意识到如何去定义,理想情况下我不必添加“string fakeString”。 I thought cref is a bit of a bummer since I thought it could only be in xml comments at the top of the method, but you can put them anywhere.
我认为 cref 有点令人失望,因为我认为它只能在方法顶部的 xml 注释中,但您可以将它们放在任何地方。
I'm going with:我要去:
/// <see cref="NewForm.HandleCommandLineArgments">
PipeClient.SendSimpleStringMessage( "scriptcode", "[Arguments]" + commandLineArguments );
In Visual Studio 2017, you can just use Ctrl + T (or whatever shortcut is assigned to Edit/Go To All
) to go to any type.在 Visual Studio 2017 中,您只需使用Ctrl + T (或分配给
Edit/Go To All
任何快捷方式)即可转到任何类型。 ReSharper has similar functionality even in earlier Visual Studio versions.即使在早期的 Visual Studio 版本中,ReSharper 也具有类似的功能。
More should not be necessary;不需要更多; and variables like your
fakeString
are really a code smell (and may even cause build/maintenance issues due to "unused variable" diagnostics).和像您的
fakeString
这样的变量fakeString
是一种代码异味(甚至可能由于“未使用的变量”诊断而导致构建/维护问题)。
If it's something that is related to the method, it's also perfectly acceptable to include links in the XML Doc via <see cref="..."/>
and/or <seealso cref="..."/>
.如果它与方法相关,那么通过
<see cref="..."/>
和/或<seealso cref="..."/>
在 XML Doc 中包含链接也是完全可以接受的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.