Is visual basic more functional than C#? Why I ask is because...

R

rss

Microsoft gives the following get available space function but no C#
function and I have seen that a lot where system functions like that
are only shown with examples for VB (Visual Basic)

Can anyone comment on this situation. Below is visual basic code for
geting free disk space
where is the C# version??

Public Function GetDiskSpace() As System.UInt64
Dim diskClass As _
New System.Management.ManagementClass("Win32_LogicalDisk")
Dim disks As System.Management.ManagementObjectCollection = _
diskClass.GetInstances()
Dim disk As System.Management.ManagementObject
Dim space As System.UInt64
For Each disk In disks
If CStr(disk("Name")) = "C:" Then
space = CType(disk("FreeSpace"), System.UInt64)
End If
Next disk
Return space
End Function
 
G

Guest

All the stuff in the VB.NET function is framwork class access, all is
available from any .NET targeted language, not just C# or VB.NET

// Example (C#)
public System.UInt64 GetDiskSpace()
{
System.Management.ManagementClass diskClass = new
System.Management.ManagementClass("Win32_LogicalDisk");
System.Management.ManagementObjectCollection disks =
diskClass.GetInstances();
System.UInt64 space = 0;
foreach (System.Management.ManagementObject disk in disks)
{
if (System.Convert.ToString(disk["Name"]) == "C:")
{
space = System.Convert.ToUInt64(disk["FreeSpace"]);
}
}
return space;
}
 
M

Michael C

Microsoft gives the following get available space function but no C#
function and I have seen that a lot where system functions like that
are only shown with examples for VB (Visual Basic)

I would imagine vb.net would be less functional but only due to some minor
issues. For example in C# comments can be added to a function by using a
triple /. These comments will appear in intellisense. Also C# has support
for pointers etc in unsafe code.

Michael
 
G

Guest

Michael C said:
I would imagine vb.net would be less functional but only due to some minor
issues. For example in C# comments can be added to a function by using a
triple /. These comments will appear in intellisense. Also C# has support
for pointers etc in unsafe code.

On the other hand, VB.net provides optional method parameters, c# does not.
This can make COM programming easier (the C# no param placeholder looks ugly,
you can however write a wrapper to hide the uglyness and only take the params
you want). The reason behind this difference is that MS decided optional
params were a bad idea, but that it would be a "overly breaking change" for
VB. Considering the degree of incompleteness in the current VB6->VB.net
converter I don't really see the logic. Broke is broke afterall.
 
J

Jeff Louie

Simply put, the development languages in .NET 2.0 are slightly
divergent. VB has
the My namespace, C# has anonymous classes, MC++ has ItJustWorks interop
and compile time const and templates etc etc.

Regards,
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top