Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

vb.net

What is the equivalent C# code for this VB.NET code?

My.Computer.FileSystem.GetFiles(....)
like image 284
Tony The Lion Avatar asked Dec 15 '09 18:12

Tony The Lion


People also ask

Can you convert VB.NET to C#?

Code Converter (VB - C#)Adds context menu items to convert projects/files between VB.NET and C#. Flexible: Convert a small selection, or a whole solution in one go, in either direction. Accurate: Full project context (through Roslyn) is used to get the most accurate conversion.

Which is faster VB.NET or C#?

It is that VB computes the loop bound once while C# computes the loop condition on each iteration. It is just a fundamental difference in the way the languages were intended to be used. ...is slightly faster than the equivalent in VB.

Which is better C# or VB?

When you will go for a job in Programming then C# will be the better choice. If you first want to learn then VB could be the better choice - it depends on what is better readable for you. In both cases : what you have to learn is not the programming-language - what you have to learn is the use of the .

Can I use VB.NET and C# in same project?

Yes its possible. adding c# and vb.net projects into a single solution. Step2: Project->Add reference->dll or exe of project which u added before.


2 Answers

The My class is VB.NET specific.

You can use the static methods of the System.IO.Directory class - e.g. Directory.GetFiles.

like image 158
Matthias Avatar answered Nov 07 '22 02:11

Matthias


You can use the VB.Net's "My" in C#. It's all code, after all. In your C# project, you'd simply add a reference to Microsoft.VisualBasic

You can check out a more detailed explanation here:

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.

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. But it's totally doable.

like image 2
Rob P. Avatar answered Nov 07 '22 02:11

Rob P.