本文介绍了每当访问共享成员时,使用类名强制执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我们有一个编码标准,说所有共享(静态)字段和方法必须用类名称调用。例如 NameOfClass.whatever 而不是 无论 有没有一个工具,我们可以用来检查这是事实吗?抱歉,我应该让它更清楚我们正在使用VB.NET。 (类似于模块) $ b 这是一个更大的例子。 公共类Class1 公共共享Sub SharedMethod() End Sub 公共共享sharedField作为整数 公共Sub NotSharedMethod()'下一行将写为Class1.SharedMethod SharedMethod() '下一行将写为Class1.sharedField sharedField = 5 End Sub 结束类别 a href =http://stackoverflow.com/questions/2131350/what-stylecop-like-tools-are-there-for-vb-net>什么StyleCop喜欢的工具,有VB.NET 解决方案对不起,我从来没有找到好的工具。 We have a coding standard that says all shared (static) fields and methods must be called with the class name. E.g.NameOfClass.whateverRather thenwhateverIs there a tool that we can use to check this is in fact the case?(Likewise for modules)Sorry I should have make it clearer we are using VB.NET.This is a bigger example of what I mean.Public Class Class1 Public Shared Sub SharedMethod() End Sub Public Shared sharedField As Integer Public Sub NotSharedMethod() 'this next line shold be written as Class1.SharedMethod SharedMethod() 'this next line shold be written as Class1.sharedField sharedField = 5 End SubEnd Classsee also What StyleCop like tools are there for VB.NET 解决方案 Sorry I never did find a good tools for this. 这篇关于每当访问共享成员时,使用类名强制执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-11 14:50