473,395 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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_LogicalDi sk")
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

Nov 17 '05 #1
5 2161
use WMI in your c# program instead :)

Nov 17 '05 #2
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_LogicalDi sk");
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;
}

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"rs*@ddsc.com" wrote:
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_LogicalDi sk")
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

Nov 17 '05 #3
<rs*@ddsc.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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
Nov 17 '05 #4


"Michael C" wrote:
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.
Nov 17 '05 #5
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

*** Sent via Developersdex http://www.developersdex.com ***
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: janice_2k | last post by:
Dear Sir/Mdm, I am writing this on behalf of my company. We bought the Visual Studio .NET Enterprise version but currently we need to use Visual Basic 6 for a small development. We are not able to...
26
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio...
3
by: Ot | last post by:
First, a bit of background... I am an experienced programmer who has been programming since 1962. Languages I know include (a partial list) FORTRAN, COBOL, Basic (a number of versions), well, I...
8
by: jdn | last post by:
I have a root application that has various sub-applications (subdirectories set up as applications within IIS). All of the sub-applications rely on the root application for profiles, membership,...
0
by: monkeycool | last post by:
This is for my intro to computer programming class. Please help me solve these 2 assignments: For the following items, you are to write the source code solution to each problem using the...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
28
by: grappletech | last post by:
I took Pascal and BASIC in a couple of beginner programming courses about a decade ago and did well with them. I am good with pseudocode, algorithms, and the mathematics of programming. I decided...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
3
by: Jon Harrop | last post by:
Microsoft have just announced that they are going to productize their functional programming language F#, placing it alongside Visual Basic: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.