PC Review


Reply
Thread Tools Rate Thread

ArrayList as a Property type

 
 
Just Me
Guest
Posts: n/a
 
      10th Aug 2004
This doesn't work. I guess New is needed someplace but I don't know where?



Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info


 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      10th Aug 2004
Hi,

Store a local copy of the arraylist to return in the property.



Public Property Filters as ArrayList

Get
Dim marFilters as New Arraylist
marFilters.Add(cboFilter.text)
return marFilters
end get


Ken
-----------------------
" Just Me" <(E-Mail Removed)> wrote in message
news:OkTPO%(E-Mail Removed)...
This doesn't work. I guess New is needed someplace but I don't know where?



Public Property Filters() As ArrayList

Get

Filters.Add(cboFilter.Text)

---snip--

Thanks in advance for any info



 
Reply With Quote
 
=?Utf-8?B?Sm9zZXBoIE1DUA==?=
Guest
Posts: n/a
 
      10th Aug 2004

August 10, 2004

The property does not maintain an instance of ArrayList itself.
You also have the concept of the property wrong. What you should
do is create a page level variable of ArrayList and then create a
sub that you call to add a filter. Then if you want to retrieve the
filters,
just access the arraylist variable directly. This looks something like:

dim filters as new ArrayList

Private Sub AddFilter()
filters.add(cbofilter.text)
End Sub

Private Sub Button1_Click(....)
if filters(0) = "Something" then
.... ' do something with list
End Sub

A property is maintained by something like this:

dim _userinput as string

Public Property UserInput() as String
Get
return _userinput
End Get
Set (byval value as string)
_userinput = value
End Set
End Property

Then you can use the property like this: Class.Userinput = Something.
I hope this makes sense! Have a good day!


Joseph MCP


"Just Me" wrote:

> This doesn't work. I guess New is needed someplace but I don't know where?
>
>
>
> Public Property Filters() As ArrayList
>
> Get
>
> Filters.Add(cboFilter.Text)
>
> ---snip--
>
> Thanks in advance for any info
>
>
>

 
Reply With Quote
 
=?Utf-8?B?Sm9zZXBoIE1DUA==?=
Guest
Posts: n/a
 
      10th Aug 2004

August 10, 2004

Wouldn't the marFilters go out of scope in your example?
Also, to only have a Get statement, the property declaration
must be marked as ReadOnly. That also looks suspiciously like
a function...

Joseph MCP


"Ken Tucker [MVP]" wrote:

> Hi,
>
> Store a local copy of the arraylist to return in the property.
>
>
>
> Public Property Filters as ArrayList
>
> Get
> Dim marFilters as New Arraylist
> marFilters.Add(cboFilter.text)
> return marFilters
> end get
>
>
> Ken
> -----------------------
> " Just Me" <(E-Mail Removed)> wrote in message
> news:OkTPO%(E-Mail Removed)...
> This doesn't work. I guess New is needed someplace but I don't know where?
>
>
>
> Public Property Filters() As ArrayList
>
> Get
>
> Filters.Add(cboFilter.Text)
>
> ---snip--
>
> Thanks in advance for any info
>
>
>
>

 
Reply With Quote
 
Just Me
Guest
Posts: n/a
 
      11th Aug 2004
Seems to work for me
Thanks

"Ken Tucker [MVP]" <(E-Mail Removed)> wrote in message
news:eJJ$(E-Mail Removed)...
> Hi,
>
> Store a local copy of the arraylist to return in the property.
>
>
>
> Public Property Filters as ArrayList
>
> Get
> Dim marFilters as New Arraylist
> marFilters.Add(cboFilter.text)
> return marFilters
> end get
>
>
> Ken
> -----------------------
> " Just Me" <(E-Mail Removed)> wrote in message
> news:OkTPO%(E-Mail Removed)...
> This doesn't work. I guess New is needed someplace but I don't know where?
>
>
>
> Public Property Filters() As ArrayList
>
> Get
>
> Filters.Add(cboFilter.Text)
>
> ---snip--
>
> Thanks in advance for any info
>
>
>



 
Reply With Quote
 
Just Me
Guest
Posts: n/a
 
      11th Aug 2004
Can someone confirm this??
The reference variable would go out of scope but the instance would not get
GC since there would still be a reference in the return.



"Joseph MCP" <(E-Mail Removed)> wrote in message
news:E87D86B2-6BBD-455E-A751-(E-Mail Removed)...
>
> August 10, 2004
>
> Wouldn't the marFilters go out of scope in your example?
> Also, to only have a Get statement, the property declaration
> must be marked as ReadOnly. That also looks suspiciously like
> a function...
>
> Joseph

MCP
>
>
> "Ken Tucker [MVP]" wrote:
>
> > Hi,
> >
> > Store a local copy of the arraylist to return in the property.
> >
> >
> >
> > Public Property Filters as ArrayList
> >
> > Get
> > Dim marFilters as New Arraylist
> > marFilters.Add(cboFilter.text)
> > return marFilters
> > end get
> >
> >
> > Ken
> > -----------------------
> > " Just Me" <(E-Mail Removed)> wrote in message
> > news:OkTPO%(E-Mail Removed)...
> > This doesn't work. I guess New is needed someplace but I don't know

where?
> >
> >
> >
> > Public Property Filters() As ArrayList
> >
> > Get
> >
> > Filters.Add(cboFilter.Text)
> >
> > ---snip--
> >
> > Thanks in advance for any info
> >
> >
> >
> >



 
Reply With Quote
 
Just Me
Guest
Posts: n/a
 
      11th Aug 2004
Thanks for the reply. It's getting late and I'm not too sharp but I'm having
a problem following your reply.

In a sense I already have a class level variable with the data in it (for
Get); or into which I want to put the data (with Set)
It is a combobox. The property is to get that data or set it.
With that said, do you still think what you wrote applies?

Thanks


"Joseph MCP" <(E-Mail Removed)> wrote in message
news:160A261A-FBAB-4F86-B29E-(E-Mail Removed)...
>
> August 10, 2004
>
> The property does not maintain an instance of ArrayList itself.
> You also have the concept of the property wrong. What you should
> do is create a page level variable of ArrayList and then create a
> sub that you call to add a filter. Then if you want to retrieve the
> filters,
> just access the arraylist variable directly. This looks something

like:
>
> dim filters as new ArrayList
>
> Private Sub AddFilter()
> filters.add(cbofilter.text)
> End Sub
>
> Private Sub Button1_Click(....)
> if filters(0) = "Something" then
> .... ' do something with list
> End Sub
>
> A property is maintained by something like this:
>
> dim _userinput as string
>
> Public Property UserInput() as String
> Get
> return _userinput
> End Get
> Set (byval value as string)
> _userinput = value
> End Set
> End Property
>
> Then you can use the property like this: Class.Userinput =

Something.
> I hope this makes sense! Have a good day!
>
>
> Joseph MCP
>
>
> "Just Me" wrote:
>
> > This doesn't work. I guess New is needed someplace but I don't know

where?
> >
> >
> >
> > Public Property Filters() As ArrayList
> >
> > Get
> >
> > Filters.Add(cboFilter.Text)
> >
> > ---snip--
> >
> > Thanks in advance for any info
> >
> >
> >



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      11th Aug 2004
* " Just Me" <(E-Mail Removed)> scripsit:
> This doesn't work. I guess New is needed someplace but I don't know where?
>
>
>
> Public Property Filters() As ArrayList
>
> Get
>
> Filters.Add(cboFilter.Text)


\\\
Private m_Filters As New ArrayList()

Public Property Filters() As ArrayList
Get
Return m_Filters
End Get
Set(ByVal Value As ArrayList)
m_Filters = Value
End Set
End Property
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
 
Reply With Quote
 
=?Utf-8?B?Sm9zZXBoIE1DUA==?=
Guest
Posts: n/a
 
      11th Aug 2004

August 10, 2004

I sounds like you already were doing the equivilant of what I wrote,
so the answer is no. But now you have me confused of what the problem
is? :-) Maybe I just need to review the posts again. Good job!


Joseph MCP

"Just Me" wrote:

> Thanks for the reply. It's getting late and I'm not too sharp but I'm having
> a problem following your reply.
>
> In a sense I already have a class level variable with the data in it (for
> Get); or into which I want to put the data (with Set)
> It is a combobox. The property is to get that data or set it.
> With that said, do you still think what you wrote applies?
>
> Thanks
>
>
> "Joseph MCP" <(E-Mail Removed)> wrote in message
> news:160A261A-FBAB-4F86-B29E-(E-Mail Removed)...
> >
> > August 10, 2004
> >
> > The property does not maintain an instance of ArrayList itself.
> > You also have the concept of the property wrong. What you should
> > do is create a page level variable of ArrayList and then create a
> > sub that you call to add a filter. Then if you want to retrieve the
> > filters,
> > just access the arraylist variable directly. This looks something

> like:
> >
> > dim filters as new ArrayList
> >
> > Private Sub AddFilter()
> > filters.add(cbofilter.text)
> > End Sub
> >
> > Private Sub Button1_Click(....)
> > if filters(0) = "Something" then
> > .... ' do something with list
> > End Sub
> >
> > A property is maintained by something like this:
> >
> > dim _userinput as string
> >
> > Public Property UserInput() as String
> > Get
> > return _userinput
> > End Get
> > Set (byval value as string)
> > _userinput = value
> > End Set
> > End Property
> >
> > Then you can use the property like this: Class.Userinput =

> Something.
> > I hope this makes sense! Have a good day!
> >
> >
> > Joseph MCP
> >
> >
> > "Just Me" wrote:
> >
> > > This doesn't work. I guess New is needed someplace but I don't know

> where?
> > >
> > >
> > >
> > > Public Property Filters() As ArrayList
> > >
> > > Get
> > >
> > > Filters.Add(cboFilter.Text)
> > >
> > > ---snip--
> > >
> > > Thanks in advance for any info
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Sm9zZXBoIE1DUA==?=
Guest
Posts: n/a
 
      11th Aug 2004

August 10, 2004

By the way, in reviewing the posts, I don't think you have the property
concept wrong. You've got it right. I was more in the mind-set of
functions,
as I didn't see the full code. Good job!


Joseph MCP

"Just Me" wrote:

> Thanks for the reply. It's getting late and I'm not too sharp but I'm having
> a problem following your reply.
>
> In a sense I already have a class level variable with the data in it (for
> Get); or into which I want to put the data (with Set)
> It is a combobox. The property is to get that data or set it.
> With that said, do you still think what you wrote applies?
>
> Thanks
>
>
> "Joseph MCP" <(E-Mail Removed)> wrote in message
> news:160A261A-FBAB-4F86-B29E-(E-Mail Removed)...
> >
> > August 10, 2004
> >
> > The property does not maintain an instance of ArrayList itself.
> > You also have the concept of the property wrong. What you should
> > do is create a page level variable of ArrayList and then create a
> > sub that you call to add a filter. Then if you want to retrieve the
> > filters,
> > just access the arraylist variable directly. This looks something

> like:
> >
> > dim filters as new ArrayList
> >
> > Private Sub AddFilter()
> > filters.add(cbofilter.text)
> > End Sub
> >
> > Private Sub Button1_Click(....)
> > if filters(0) = "Something" then
> > .... ' do something with list
> > End Sub
> >
> > A property is maintained by something like this:
> >
> > dim _userinput as string
> >
> > Public Property UserInput() as String
> > Get
> > return _userinput
> > End Get
> > Set (byval value as string)
> > _userinput = value
> > End Set
> > End Property
> >
> > Then you can use the property like this: Class.Userinput =

> Something.
> > I hope this makes sense! Have a good day!
> >
> >
> > Joseph MCP
> >
> >
> > "Just Me" wrote:
> >
> > > This doesn't work. I guess New is needed someplace but I don't know

> where?
> > >
> > >
> > >
> > > Public Property Filters() As ArrayList
> > >
> > > Get
> > >
> > > Filters.Add(cboFilter.Text)
> > >
> > > ---snip--
> > >
> > > Thanks in advance for any info
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread-safety: Change property of items in arraylist versus removingitems from the arraylist Curious Microsoft Dot NET 2 6th Aug 2008 12:36 PM
Designer Controls With ArrayList type property. Alvaro E. Gonzalez V. Microsoft C# .NET 3 13th Mar 2007 12:18 AM
ArrayList property: requiring type for elements Jeroen Microsoft C# .NET 8 18th Oct 2006 11:59 AM
DataBinder.Eval and an ArrayList type property Mark Jones Microsoft ASP .NET 3 2nd Jan 2006 02:22 PM
a class inherited from ArrayList, is saved to ViewState, why the type of the object read from ViewSate is not the class, but the parent, ArrayList leal ting Microsoft ASP .NET 0 29th Dec 2003 07:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:42 PM.