如何计算项目中的类数(How to calculate number of classes in a project)

编程入门 行业动态 更新时间:2024-10-28 08:20:45
如何计算项目中的类数(How to calculate number of classes in a project)

我们正在处理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.

更多推荐

本文发布于:2023-07-21 09:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1209031.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   calculate   number   classes   project

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!