473,387 Members | 1,575 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,387 software developers and data experts.

Help!! How do I delete part of an array?

34
Hi,
I am very much a beginner and would love some help here.
I seem to get a blank line in the text box I am getting these entries from and I wanted to check for that in my array and then delete that part of the array (which would be the last entry).
But I am not sure what to put for the start index for the Remove method.

//if there are blank lines in the array, remove them
for (int i = 0; i < EntriesArray.Length; i++)
{
if (EntriesArray[i] == "")
{
EntriesArray[i].Remove( --what goes here?-- );
}
}

I see from the intellisense it is the start index...but when I put in 0 for starting at the beginning it doesn't work.

Thanks so much!
JL
Apr 10 '07 #1
3 1393
SammyB
807 Expert 512MB
Hi,
I am very much a beginner and would love some help here.
I seem to get a blank line in the text box I am getting these entries from and I wanted to check for that in my array and then delete that part of the array (which would be the last entry).
But I am not sure what to put for the start index for the Remove method.

//if there are blank lines in the array, remove them
for (int i = 0; i < EntriesArray.Length; i++)
{
if (EntriesArray[i] == "")
{
EntriesArray[i].Remove( --what goes here?-- );
}
}

I see from the intellisense it is the start index...but when I put in 0 for starting at the beginning it doesn't work.

Thanks so much!
JL
How have you defined EntriesArray?
Apr 10 '07 #2
nmsreddi
366 256MB
Hello

Why you want to delete part of an array that too from your code you are trying to delete empty entries,which part of an array you want to delete,that starting in the middle to end or some entries in the middle only ,are you able to get the length of your array will it be constant or variable.

can you give some details so that i can reply
Apr 11 '07 #3
JLC
34
Well I ended up using a list instead of an array. It made it easier to remove entries should they be blank.

SO I ended up with something like this.

//Check if the Old Public Key entered and the Domain are
//in the registry..if not return error
List<string> domainEntriesArray = new List<string>();
foreach(string entry in richTextBoxDomainPK.Lines)
{
domainEntriesArray.Add(entry);
}
//domainEntriesArray = richTextBoxDomainPK.Lines;
// string[] domainEntriesArray = richTextBoxDomainPK.Lines;
StringBuilder rejectedEntries = new StringBuilder();

//if there are blank lines in the array, remove them
for (int i = 0; i < domainEntriesArray.Count; i++)
{
if (String.IsNullOrEmpty(domainEntriesArray[i]))
{
domainEntriesArray.Remove(domainEntriesArray[i]);
}
}

Thanks everyone for the responses!

JLC
Apr 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Westcoast Sheri | last post by:
Any way to do a simple delete from array? In other words, what would be the *easiest* (and fastest php runtime) way to delete "banana" from the following array: $my_array = array( "apple",...
6
by: Sowen | last post by:
hi, I have the following code object obj_1; object obj_2; object obj_3; object *objs = { &obj_1, &obj_2, &obj_3 };
10
by: felixnielsen | last post by:
Hi, im pretty new to this so plz cut me some slag ;-) anyhow, i need to delete an array, or what i really need is to increase the array size, i was think i could be done by copying the array into...
1
by: Benton2862 | last post by:
I need help with and array for a program that acts like a cash register. The user will input an items price and then there payment. It will tell you the change and then tell you what kinda of change...
6
by: Ananas | last post by:
Hi, My native C++ function creates a dynamic array. I'm marshalling it to managed code and got to delete after. How to make it: c++ code: void CreateArrayInside( pTestStruct &TestStruct,...
2
dbanning
by: dbanning | last post by:
I am trying to remove part of a string and place it into another variable the string is a filename eg "C:\help\demo\sample.txt" I want to remove and resave into a new string just the file...
3
by: karthigeyantp | last post by:
hi, i have declared array at 1st ,in middel of the program i want to delete the array how to do it.
4
by: Abhijitit | last post by:
Hello, I have Class name as MyClass and created multidimesional array of object. Example is given below. // clr_array.cpp // compile with: /clr ref class MyClass {}; int main() { ...
5
dlite922
by: dlite922 | last post by:
I can't believe I haven't come across this in all of my PHP programming (or my brain is currently locked)...I need to delete an array from an array that i'm traversing through with a foreach. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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,...

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.