我们正在处理VB6和.NET项目,需要计算类的数量。
对于vb6,我们总结了标准和类模块的总数,它们给出了项目中的类总数。
对于.NET,我们计算文件后面的代码总数,在独立的.vb或.cs文件中,我们计算内部定义的类的数量。 该总数被视为最终计数。
它是否正确? 或者在.NET中是独立的.vb或.cs文件,应该被认为是1类,而不是计算这个文件中的类?
We are dealing with VB6 and .NET project and need to calculate the number of classes.
For vb6 we sum up the total number of standard and class modules which gives us the total number of classes in project.
For .NET we calculate the total number of code behind files, and in standalone .vb or .cs files we calculate the number of classes defined inside. This total is considered as final count.
Is this correct? or in .NET is the standalone .vb or .cs file supposed to be considered as 1 class rather than counting the classes inside this file??
最满意答案
For .NET we calculate the total number of code behind files, and in standalone .vb or .cs files we calculate the number of classes defined inside. This total is considered as final count.
Is this correct? or in .NET is the standalone .vb or .cs file supposed to be considered as 1 class rather than counting the classes inside this file??
不,您无法确定计数文件是否可以显示总类数。
原因 1. .cs或.vb文件中可以有多个类。 尽管在代码文件中只有一个类是一个好习惯,但.Net并不限制您在文件中包含多个类。 2.通过在C#中使用partial关键字和在VB.Net中使用Partial关键字,可以在多个文件中存在一个类。
因此,总是计算.Net中不同的类名。
For .NET we calculate the total number of code behind files, and in standalone .vb or .cs files we calculate the number of classes defined inside. This total is considered as final count.
Is this correct? or in .NET is the standalone .vb or .cs file supposed to be considered as 1 class rather than counting the classes inside this file??
No you cannot be sure that counting files can reveal total number of classes.
Reason 1. There can be more than one class in a .cs or .vb file. Although it is a good practice to have only one class in a code file but .Net does not restrict you to have more than one class in a file. 2. A class can exist in multiple files through the use of partial keyword in C# and Partial keyword in VB.Net.
Hence always count the distinct names of classes in .Net.
更多推荐
发布评论