简体   繁体   English

VB.NET到C# - my.computer.getfiles()

[英]VB.NET to C# - my.computer.getfiles()

这个VB.NET代码的等效C#代码是什么?

My.Computer.FileSystem.GetFiles(....)

The My class is VB.NET specific. My类是VB.NET特有的。

You can use the static methods of the System.IO.Directory class - eg Directory.GetFiles. 您可以使用System.IO.Directory类的静态方法 - 例如Directory.GetFiles。

You can use the VB.Net's "My" in C#. 可以在C#中使用VB.Net的“我的”。 It's all code, after all. 毕竟,这都是代码。 In your C# project, you'd simply add a reference to Microsoft.VisualBasic 在您的C#项目中,您只需添加对Microsoft.VisualBasic的引用

You can check out a more detailed explanation here: 您可以在此处查看更详细的说明:

http://www.codeproject.com/KB/cs/MyNamespace.aspx http://www.codeproject.com/KB/cs/MyNamespace.aspx

I don't think there is anything in 'My' that you can't achieve without using it; 我不认为“我的”中没有任何东西可以在不使用它的情况下实现; but just because you aren't programming in VB.Net you have to not use it. 但仅仅因为你没有在VB.Net中编程,你必须使用它。

Having said all that - most architect type people I know would roll their eyes at you if they saw you adding a reference to VisualBasic in a C# project. 说了这么多 - 如果他们看到你在C#项目中添加对VisualBasic的引用,我认识的大多数建筑师类型的人都会盯着你。 But it's totally doable. 但它完全可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM