473,513 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

possibe to delete string from string[] ?

I wanted to truncate a string array by removing the last item.
"strResult.length = n-1" does not work as the length is read only. I tried
strResult[n] = null and just got a null. Also tried strResult[n].Remove(0)
and all it did was delete characters, not remove the string. I can create a
string the correct size using "new string [n-1]" and then copy but it seems
there should be an easier way. I cant seem to make VS 2008 get me good help
on "string[]" It is not the same as StringBuilder and is just an array of
strings is it not?

...TIA..

Nov 19 '08 #1
2 2551
"Beemer Biker" <js*******@swri.eduwrote in message
news:D3**********************************@microsof t.com...
I can create a string the correct size using "new string [n-1]" and then
copy but it seems there should be an easier way.
Nope. When working with a plain old array, that's all you get. You ought to
consider using List<stringinstead. It still does that under the covers,
but up front you get nice things like Remove().
Nov 19 '08 #2
By design arrays are of fixed side. I would suggest using a generic List of
strings: List<string>, which you can manipulate as you wish. Removing the
last item can be done by calling "lst.RemoveAt(lst.Count - 1)".
--
Stanimir Stoyanov
http://stoyanoff.info

"Beemer Biker" <js*******@swri.eduwrote in message
news:D3**********************************@microsof t.com...
>I wanted to truncate a string array by removing the last item.
"strResult.length = n-1" does not work as the length is read only. I tried
strResult[n] = null and just got a null. Also tried strResult[n].Remove(0)
and all it did was delete characters, not remove the string. I can create a
string the correct size using "new string [n-1]" and then copy but it seems
there should be an easier way. I cant seem to make VS 2008 get me good
help on "string[]" It is not the same as StringBuilder and is just an
array of strings is it not?

..TIA..
Nov 19 '08 #3

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

Similar topics

6
2565
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
2
4128
by: andy | last post by:
Hi I have a requirement to submit form data to a url after collecting the data from the database. For example I need to send firstname and lastname through a post method I can call on the...
3
4634
by: silver360 | last post by:
Hello, I'm trying to create a basic Heap manager and i have some question about new/delete overloading. The following code give me this output : >> $./heap >> registered : 0x804d098 >>...
19
2578
by: Xavier Décoret | last post by:
Hi, I long thought one could not delete a const pointer but the following code compiles under g++ and visual net: class Dummy { public: Dummy() {} ~Dummy() {}
6
281
by: Nethali | last post by:
Hi all, Please explain me the following: I have struct as follows: struct Link { void* data; Link* next;
5
3902
by: sh26 | last post by:
I can Add and Delete (A, CName, MX and TXT) Dns records on the Dns Server using C# code. The problem I am having is if someone manaully creates a TXT record on the Dns Server, I cannot delete that...
7
6906
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI...
1
2326
by: jmarcrum | last post by:
Hello all! i have a “monitor-type” program, where my program recognizes my defined "commands”, and executes the given command, or produces an error message that says “unrecognized command”. After...
2
2472
by: Danielle | last post by:
Hello all - Thank you in advance for any help you are able to provide. I am populating a gridview from a stored procuedure. The returned data is a name, phone number, email and guid of a...
0
7153
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
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
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...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
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
5677
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,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
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
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.