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

question about get/set properties

Hello,

If I want to store a value and keep that value through postbacks, I've
used code like this before...

Private _MyName As String

Public Property MyName() As String
Get
_MyName = Me.ViewState("MyName").ToString
Return _MyName
End Get
Set(ByVal value As String)
_MyName = value
Me.ViewState("MyName") = _MyName
End Set
End Property

But this only stores one value... what if a need arises to store
multiple values? And since I'm assuming one might want to store any
given number of values then I'll need a container which can grow. So I
tried something like this...

Private _myMatches As ArrayList

Public Property myMatches() As ArrayList
Get
_myMatches = Me.ViewState("myMatches")
Return _myMatches
End Get
Set(ByVal value As ArrayList)
_myMatches = value
Me.ViewState("myMatches") = _MyName
End Set
End Property

The problem comes in when I try to start throwing values in the
property. In the logic which loops through values which may need to be
stored, I have this snip of code:

' i is the counter used for itterations through the loop
myMatches.Capacity = i
myMatches.Item(i) = currentString

This code throws a null reference exception on the "myMatches.Capacity
= i" line. I made an assumption that the array list size needs to be
specified -- hence the Capacity property (kinda like ReDim'ing a plain
'ol array at runtime). But if that Capacity line is removed the null
reference exception is just thrown on the next line.

Suggestions are greatly appreciated. Thanks!

Jul 5 '06 #1
0 890

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

Similar topics

4
by: lawrence | last post by:
Suppose I have this table: CREATE TABLE properties ( id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL default '', modifierText text NOT NULL, modifierChar char(1) NOT NULL...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
6
by: amethyste | last post by:
hello, This is my sample (simplified): public class Binom { public string _Value;
15
by: designconcepts | last post by:
bo'jour, bo'jour, So I have question to present to the forum about OOD. This is a Csharp forum, but C# is the lang of choice and the question is an exercise based on some comments by the chief...
12
by: einar | last post by:
I have aa situation and i don't know if what i want to do is possible. I have a class named Account with some properties and i set values for these properties like this. public void foo() {...
14
by: 42 | last post by:
Hi, Stupid question: I keep bumping into the desire to create classes and properties with the same name and the current favored naming conventions aren't automatically differentiating them......
14
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
0
by: AdamKadmon | last post by:
Hello Group, Below is (mostly)functional code that enumerates certain properties for all of the groups in my Active Directory. My question is contained within comments as well as here: Once I...
6
by: RSH | last post by:
I am still trying to grasp the use of real world Objects and how to conceptualize them using a business scenerio. What I have below is an outline that I am wrestling with trying to figure out a...
11
by: manstey | last post by:
Hi, I am having trouble designing my classes. I have two classes. The first one wraps around an old-style class called oref Class CacheClass(object): def __init__(self, obj):
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.