创建带有接口的类。然后在代码隐藏中迭代它
我有一个关于包含接口的类的问题。我有大约 12 个类,它们的接口都相同。现在,我需要列出所有课程。该功能中可能会创建 1000 个新类别。但由于它们负责设备,有时某些类已经过时了。
好的。 列出所有类是没有问题的
dim ClassList as new List(Of MyInterface)
ClassList.Add(New MyFirstItem())
ClassList.Add(New MySecondItem())
ClassList.Add(New MyThirdItem())
ClassList.Add(New ...)
使用我现在
For each item as MyInterface in ClassList
'Print info
next
正在做的事情
。 我想问是否可以告诉 Visual Studio 或我的应用程序,我有一个解决方案文件夹,其中写入了所有类,并自动将这些项目添加到列表中。或者像插件一样做。我想避免上面的行。我想避免仅仅为每个类中的某些代码行创建一个完整的新项目。
ClassList.Add(New ...) 'would like to avoid this to do manually
只是为了创建一个实例并立即再次处理它以在屏幕上写入类信息。
希望我能解释我的问题
问候
I have a question about classes with including interfaces. I have about 12 classes with all the same interface in it. Now, I need to list all classes. In the feature there could be 1000 new classed to create. But because they are responsible for devices some times some classes are obsolete.
Ok. No problem to list all classes by using
dim ClassList as new List(Of MyInterface)
ClassList.Add(New MyFirstItem())
ClassList.Add(New MySecondItem())
ClassList.Add(New MyThirdItem())
ClassList.Add(New ...)
then
For each item as MyInterface in ClassList
'Print info
next
that what I am doing NOW.
I want to ask if it is possible tell visual studio or my application that I have one solution folder with all classes written in and to add automatically these items to the list. Or do it like plugins. I want to avoid the lines above. And I want to avoid creating a complete new project just for some lines of code in each class.
ClassList.Add(New ...) 'would like to avoid this to do manually
just to create an instance and dispose it immediately again for writing the class information on screen.
Hope I could explain my question
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的所有类都位于各自的文件中,并在目录中命名为它们的类名,您可以做一个小应用程序,将您的行输出到文本文件,如下所示:
Assuming all of your classes are in their own files named their class name in the directory you could do a little app that would output your lines to a text file like this: