473,469 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB6.0 to newbie C#

Is there a C# equivalent to Vb6's Erase when dealing with arrays?
Also vb6 handles the long variable type better (speedwise) than int.
Is this also the case in C#?
TIA Mick.
Jun 27 '08 #1
2 1608
"Michael Harrington" <mi*****@bigpond.comwrote in message
news:e4**************@TK2MSFTNGP05.phx.gbl...
Is there a C# equivalent to Vb6's Erase when dealing with arrays?
If I remember correctly, VB6 Erase removed all elements of an array and
left the array with length zero. In C#, you could achieve a similar effect
by assigning a new array with zero elements:

string[] theArray = ...;
....
theArray = new string[0];

Or, if you don't need to use it as a referece, just set it to null:

theArray = null;
Also vb6 handles the long variable type better (speedwise) than int.
Is this also the case in C#?
In C# the int type is 32-bits wide, therefore it is equivalent to the
Long type in VB6. The old Integer in VB6 (16-bits) would be a "short" in C#.

Jun 27 '08 #2
On Wed, 28 May 2008 01:30:02 -0700, Alberto Poblacion
<ea******************************@poblacion.orgwro te:
"Michael Harrington" <mi*****@bigpond.comwrote in message
news:e4**************@TK2MSFTNGP05.phx.gbl...
>Is there a C# equivalent to Vb6's Erase when dealing with arrays?

If I remember correctly, VB6 Erase removed all elements of an array
and left the array with length zero.
Looking at the docs, it appears to me that Erase simply removes the array
altogether, leaving the identifier unusable until the array is "ReDim"'ed.

In that respect, I think assigning the array to null is closer to the
actual idea the OP has.

However: according to the docs, Erase is strictly a procedure-level
thing. It can only be used on local variables. In C#, assigning a local
variable to null is pointless. The compiler already can tell whether a
local variable is used past some point within the method body, and makes
the object a variable references eligible for garbage collection if that
variable isn't used again within the method. All that assigning to null
does is extend the lifetime of that object to the point where the variable
was assigned to null.

In other words, the correct answer to the OP is very likely: the best
"equivalent" in C# to the Erase statement is to do nothing at all.

Pete
Jun 27 '08 #3

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

Similar topics

4
by: Philippe C. Martin | last post by:
Hi, Is there a program out there that would generate the C code to instantiate objects and call them: ex: miracle.exe -i mymodule.py -o module_internface.c ? I seem to recall a _yes_ to...
0
by: Twayne | last post by:
Twayne wrote: That's the verification I was looking for I think. There are times that doesn't seem to be so, but perhaps I'll looking at the wrong side of the tree in the wrong forest ... I...
5
by: Banibrata Dutta | last post by:
Hi, I've gone through the list of "language differences" between 2.3 / 2.4 & 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of CPython, and I consider myself still very very...
16
by: Raxit | last post by:
Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy...
10
by: Peter Michaux | last post by:
On May 14, 8:55 pm, Prisoner at War <prisoner_at_...@yahoo.comwrote: Get it from the library. I cannot imagine needing to own an HTML book. There are plenty of good references on the web....
2
by: r_ahimsa_m | last post by:
Could you recommend me some free JavaScript validator? I was using JSlint but it reports nonsense errors. Please help. Thanks. /RAM/
6
by: raylopez99 | last post by:
Will ASP.NET 3.0 work under Visual Studio 2005? And what is a good newbie ASP.NET book? Subject: Will ASP.NET 3.0 work under Visual Studio 2005? And what is a good newbie ASP.NET book? My...
3
Lokean
by: Lokean | last post by:
Sorry for this newbie question, this is not my realm of expertese. I have searched google, tried several applications that claim they can do this, such as Mapforce, which I found confusing, to...
5
by: Dave | last post by:
I am new to Visual Web Developer 2005 Expres. I am using absolute positioning and every time I add a button control to my web form its width extends all the way to the edge of the page. IOW I...
5
by: SharkD | last post by:
Hi! I'm a total newbie when it comes to ASP (or any type of server-side programming). I want to start a project that does the following: 1. query Wikipedia for information regarding...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.