hi all
i've created a strong named collection which inherits collection base,but
when i try to add to it a nullreferenceex ception blows.
the code is as listed below. do i have to init the list myself.
any hints...please!
thanks all
Public Class NewKeys
Inherits BaseCollection
Default Public Property Item(ByVal Index As Integer) As NewKey
Get
Return CType(list(Inde x), NewKey)
End Get
Set(ByVal Value As NewKey)
List(Index) = Value
End Set
End Property
Public Overrides ReadOnly Property Count() As Integer
Get
Return (MyBase.List.Co unt())
End Get
End Property
Public Function Add(ByVal value As NewKey) As Integer
Try
Return List.Add(value)
Catch e As Exception
messagebox.show (e.ToString) <------------ it blows here
debug.writeline (e.tostring())
End Try
End Function 'Add
Public Function IndexOf(ByVal value As NewKey) As Integer
Return List.IndexOf(va lue)
End Function 'IndexOf
Public Sub Insert(ByVal index As Integer, ByVal value As NewKey)
List.Insert(ind ex, value)
End Sub 'Insert
Public Sub Remove(ByVal value As NewKey)
List.Remove(val ue)
End Sub 'Remove
Public Function Contains(ByVal value As NewKey) As Boolean
' If value is not of type newkey, this will return false.
Return List.Contains(v alue)
End Function
End Class 4 1801
> messagebox.show (e.ToString) <------------ it blows here
try
e.Message
eric
"Majed" <am******@hotma il.com> wrote in message
news:ej******** *******@TK2MSFT NGP11.phx.gbl.. . hi all i've created a strong named collection which inherits collection base,but when i try to add to it a nullreferenceex ception blows. the code is as listed below. do i have to init the list myself. any hints...please! thanks all
hi
e.tostring gives me more information
thanks
"EricJ" <er********@Thi Sbitconsult.be. RE> wrote in message
news:e2******** ******@TK2MSFTN GP12.phx.gbl... messagebox.show (e.ToString) <------------ it blows here
try e.Message
eric
"Majed" <am******@hotma il.com> wrote in message news:ej******** *******@TK2MSFT NGP11.phx.gbl.. . hi all i've created a strong named collection which inherits collection
base,but when i try to add to it a nullreferenceex ception blows. the code is as listed below. do i have to init the list myself. any hints...please! thanks all
Majed, Public Class NewKeys Inherits BaseCollection
Have you tried inheriting from System.Collecti on.CollectionBa se instead of
System.Windows. Forms.BaseColle ction?
CollectionBase contains a List property for you ready to use, while
BaseCollection requires you to override the List property and return an
ArrayList to use.
Overall CollectionBase and other classes from System.Collecti on &
System.Collecti on.Specialized are the classes you should be using...
Hope this helps
Jay
"Majed" <am******@hotma il.com> wrote in message
news:ej******** *******@TK2MSFT NGP11.phx.gbl.. . hi all i've created a strong named collection which inherits collection base,but when i try to add to it a nullreferenceex ception blows. the code is as listed below. do i have to init the list myself. any hints...please! thanks all
Public Class NewKeys
Inherits BaseCollection
Default Public Property Item(ByVal Index As Integer) As NewKey
Get
Return CType(list(Inde x), NewKey)
End Get
Set(ByVal Value As NewKey)
List(Index) = Value
End Set
End Property
Public Overrides ReadOnly Property Count() As Integer
Get
Return (MyBase.List.Co unt())
End Get
End Property
Public Function Add(ByVal value As NewKey) As Integer
Try
Return List.Add(value)
Catch e As Exception
messagebox.show (e.ToString) <------------ it blows here
debug.writeline (e.tostring())
End Try
End Function 'Add
Public Function IndexOf(ByVal value As NewKey) As Integer
Return List.IndexOf(va lue)
End Function 'IndexOf
Public Sub Insert(ByVal index As Integer, ByVal value As NewKey)
List.Insert(ind ex, value)
End Sub 'Insert
Public Sub Remove(ByVal value As NewKey)
List.Remove(val ue)
End Sub 'Remove
Public Function Contains(ByVal value As NewKey) As Boolean
' If value is not of type newkey, this will return false.
Return List.Contains(v alue)
End Function
End Class
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:Ok******** ******@tk2msftn gp13.phx.gbl... Majed, Public Class NewKeys Inherits BaseCollection
Have you tried inheriting from System.Collecti on.CollectionBa se instead of System.Windows. Forms.BaseColle ction?
CollectionBase contains a List property for you ready to use, while BaseCollection requires you to override the List property and return an ArrayList to use.
Overall CollectionBase and other classes from System.Collecti on & System.Collecti on.Specialized are the classes you should be using...
Hope this helps Jay
it sure dose
thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Colin Basterfield |
last post by:
Hi,
I have a list which is derived from CollectionBase, and it contains a list
of User objects, which I want to Serialize out to an XML file.
Is there anywhere where I can find how to decode it so that it recognizes
what objects are held in my list? or an example in C# prefereably?
Many thanks in advance...
Colin
|
by: Colin Basterfield |
last post by:
Hi,
I have two lists, the first is the complete list, so call it PermList, the
second is a subsection of that list, call this TempList, both are of the
same type, naemly strongly typed and derived from CollectionBase.
I assume that if I simply iterate thro the PermList list taking the elements
that I want and simply add them to TempList then, when I want to clear the
TempList in order to add the next subsection from PermList, by simply...
|
by: jason |
last post by:
Hello. I've got this simple collection populate code I downloaded from
the net (sorry can't find source now) I'm trying to test, but I can't
seem to get it to work. Any help would be greatly appreciated.
I've compiled the following VB.NET into a DLL:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
|
by: Majed |
last post by:
hi all
i've created a strong named collection which inherits collection base,but
when i try to add to it a nullreferenceexception blows.
the code is as listed below. do i have to init the list myself.
any hints...please!
thanks all
Public Class NewKeys
Inherits BaseCollection
|
by: moondaddy |
last post by:
I wrote my own List class which I use to bind to list controls. this class
inherits CollectionBase and implements IBindingList. This class contains a
list of business classes such as customers for example. In the customer
class I have an event called MyTestEvent and when certain conditions arise,
I want to raise this event which would cause an event to fire in the List
class. How can this be done when I don't actually declare the...
| |
by: Yuk Tang |
last post by:
I am tearing my hair out over this, since I can't see what I'm doing
wrong (duh, if I knew, I wouldn't be asking the question). I am
adding Field items to a Field Collection, but for some reason it
wants to start from the beginning and overwrite all entries before
adding the latest member. I've added a couple of msgboxes to
illustrate this, one at the add method, another cycling through the
collection after the addition has been made.
...
|
by: Demetri |
last post by:
I have a collection class that inherits from CollectionBase. I am using the
List.Remove method to remove an object in the collection. When I use it, I
get the following error:
Exception Details: System.Runtime.Serialization.SerializationException: The
type MyEntity in Assembly MyBusiness, Version=1.0.2263.29542,
Culture=neutral, PublicKeyToken=null is not marked as serializable.
What gives?
|
by: Tony |
last post by:
Hello!
Here I have a collection class Cards which is derived from the Base class
CollectionBase.
This class Cards is a container for Card object.
Now to my question at the bottom of this class we have a method called
Contains.
It gived the same result to use InnerList and List in this method Contains.
I can also just replace List with InnerList in the method Add and it works.
|
by: Tony Johansson |
last post by:
Hello!
Sorry for opening up this task again.
I want to fully understand this List that is return from CollectionBase.
According to you is List in CollectionBase implemented something like the
below which you sent me previously. So the referenced type for List that
will be
returned at execution time must be CollectionBase. The compile type for List
|
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...
|
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,...
| |
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |