473,663 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PropertyDescrip torCollection.R emove()

Hi all,

I have a general question concerning the capability of the
PropertyDescrip torCollection. It seems to be impossible to remove a
PropertyDescrip tor savely using Remove or RemoveAt. I use framework
1.1. Why does the following code always crash resulting in the error
message "Source array was not long enough. Check srcIndex and length,
and the array's lower bounds.":

PropertyDescrip torCollection PDC = new
PropertyDescrip torCollection(n ull);
PDC.Add(new MyItemDescripto r(null, "first", ""));
PDC.Add(new MyItemDescripto r(null, "second", ""));
PDC.RemoveAt(0) ;

But removing the second element works this time:

PropertyDescrip torCollection PDC = new
PropertyDescrip torCollection(n ull);
PDC.Add(new MyItemDescripto r(null, "first", ""));
PDC.Add(new MyItemDescripto r(null, "second", ""));
PDC.RemoveAt(1) ;

For me it's impossible to foresee when it will fail, sometimes it's
removable sometimes not.

Thanks in advance,

Frank
Jul 21 '05 #1
1 2225
Im having the same problem. I stepped through my code, and the Length of
the PropertyDescrip torCollection implementation was 2, when I got this
error.

It was trying to remove element at position 0.

Brian Takita

FrankYM wrote:
Hi all,

I have a general question concerning the capability of the
PropertyDescrip torCollection. It seems to be impossible to remove a
PropertyDescrip tor savely using Remove or RemoveAt. I use framework
1.1. Why does the following code always crash resulting in the error
message "Source array was not long enough. Check srcIndex and length,
and the array's lower bounds.":

PropertyDescrip torCollection PDC = new
PropertyDescrip torCollection(n ull);
PDC.Add(new MyItemDescripto r(null, "first", ""));
PDC.Add(new MyItemDescripto r(null, "second", ""));
PDC.RemoveAt(0) ;

But removing the second element works this time:

PropertyDescrip torCollection PDC = new
PropertyDescrip torCollection(n ull);
PDC.Add(new MyItemDescripto r(null, "first", ""));
PDC.Add(new MyItemDescripto r(null, "second", ""));
PDC.RemoveAt(1) ;

For me it's impossible to foresee when it will fail, sometimes it's
removable sometimes not.

Thanks in advance,

Frank

Jul 21 '05 #2

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

Similar topics

12
55548
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are also removed) So far I have (val is value, ar is array, returns new array):
11
3070
by: Tony Johansson | last post by:
Hello! I have some problem with STL function remove I have two classes called Handle which is a template class and Integer which is not a template class. The Integer class is just a wrapper class for a primitive int with some methods. I don't show the Integer class because it will not add any information to my problem. Main is using some STL function Now to my problem.
6
4941
by: Arne Claus | last post by:
Hi If've just read, that remove() on a list does not actually remove the elements, but places them at the end of the list (according to TC++STL by Josuttis). It also says, that remove returns a new, logical end pointer, so that the following myList::iterator end = myListObj.remove(myInt); myListObj.erase(end, myListObj.end()); is possible and removes the "invalid" items at the end of the list.
3
3801
by: Don | last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods. The "Add" method is working great. However I don't understand why the "Remove" method isn't working. It neither removes the item from the arraylist nor from the combobox like it's supposed to do. A couple of notes: cbx is the name of the combobox within my usercontrol, file is the name of the arraylist within my usercontrol. To try...
1
411
by: FrankYM | last post by:
Hi all, I have a general question concerning the capability of the PropertyDescriptorCollection. It seems to be impossible to remove a PropertyDescriptor savely using Remove or RemoveAt. I use framework 1.1. Why does the following code always crash resulting in the error message "Source array was not long enough. Check srcIndex and length, and the array's lower bounds.": PropertyDescriptorCollection PDC = new
3
5399
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some example first:
6
7175
by: tshad | last post by:
Is there a reason to use session.remove over session.contents.remove? Don't they both remove the key and data from the contents collection? I assume that session(x) = nothing does essentially the same thing but is actually deleted later by the GC. Thanks, Tom
7
6601
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer include them in the set that is displayed to the user) but I don't want to delete the corresponding row from the database. I've tried using the .Rows.Remove() method but an exception is thrown to say I don't have a 'delete' command in the data...
6
5995
by: sam_cit | last post by:
Hi Everyone, I'm using remove() function to delete a file, and i observed the following behavior, Concerned file : sample.txt Operation : i open the file in read mode and don't close the file. remove() returns -1 and the file is not deleted. The above operation is successful when i close the file just before
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8548
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4182
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.