473,327 Members | 2,012 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,327 software developers and data experts.

Making a collection inside a class

How do you make a collection inside a class and then access it? I am trying
to make a class that is a news item and dont know where to really start. Any
ideas?

Nov 16 '07 #1
4 1758
Hi Stranger,

first at all: Real Names please!

Depending on your need you can declare the Collection
as a variable, with appropriate scope or the way i recommend
and i think is always the right you should make the collection
a class property, also with apropriate scope, where scope stands
for access modifiers like private, protected, internal, public or
whatever your project needs. keep in mind that you should code
with pragmatic in mind: Safe Initialization and complete cleanup.

Thats what i recommend,...others may not or they will follow
another aproach,...
Cheers,...

Kerem

--
---------
New Open Source Tools from me:
Calculate MD5 or SHA1 Hash for Files!
KHash Tools:
http://entwicklung.junetz.de/project...ls%20v.1.0.zip
---------
Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
ke*****@arcor.de

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/

-----------------------
"This reply is provided as is, without warranty express or implied."
Nov 16 '07 #2
Is there a way you can give me a code example? Nothing too huge but
something enough to give me an idea of what I'm doing...
"Kerem Gümrükcü" <ka*******@hotmail.comwrote in message
news:e3**************@TK2MSFTNGP06.phx.gbl...
Hi Stranger,

first at all: Real Names please!

Depending on your need you can declare the Collection
as a variable, with appropriate scope or the way i recommend
and i think is always the right you should make the collection
a class property, also with apropriate scope, where scope stands
for access modifiers like private, protected, internal, public or
whatever your project needs. keep in mind that you should code
with pragmatic in mind: Safe Initialization and complete cleanup.

Thats what i recommend,...others may not or they will follow
another aproach,...
Cheers,...

Kerem

--
---------
New Open Source Tools from me:
Calculate MD5 or SHA1 Hash for Files!
KHash Tools:
http://entwicklung.junetz.de/project...ls%20v.1.0.zip
---------
Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
ke*****@arcor.de

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/

-----------------------
"This reply is provided as is, without warranty express or implied."


Nov 16 '07 #3
On 16 Nov, 08:48, "Andy B" <a_bo...@sbcglobal.netwrote:
Is there a way you can give me a code example? Nothing too huge but
something enough to give me an idea of what I'm doing...

"Kerem Gümrükcü" <kareem...@hotmail.comwrote in message

news:e3**************@TK2MSFTNGP06.phx.gbl...
Hi Stranger,
first at all: Real Names please!
Depending on your need you can declare the Collection
as a variable, with appropriate scope or the way i recommend
and i think is always the right you should make the collection
a class property, also with apropriate scope, where scope stands
for access modifiers like private, protected, internal, public or
whatever your project needs. keep in mind that you should code
with pragmatic in mind: Safe Initialization and complete cleanup.
Thats what i recommend,...others may not or they will follow
another aproach,...
Cheers,...
Kerem
--
---------
New Open Source Tools from me:
Calculate MD5 or SHA1 Hash for Files!
KHash Tools:
http://entwicklung.junetz.de/project...ools/khashtool...
---------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
kere...@arcor.de
Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2
Latest Open-Source Projects:http://entwicklung.junetz.de
Sign my guestbook:http://entwicklung.junetz.de/guestbook/
-----------------------
"This reply is provided as is, without warranty express or implied."- Hide quoted text -

- Show quoted text -
Here's a dotnet 2 class that shows the basics using a generic
dictionary. You can use similar techniques with a List amongst others
depending on your requirements. Collections is quite a broad topic
though.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.CompilerServices;

namespace ClassLibrary1
{
public class Indexy
{
private Dictionary<string, string_bits = new
Dictionary<string, string>();

[IndexerName("Value")]
public string this[String key]
{
set
{
if (_bits.ContainsKey(key))
{
_bits[key] = value;
}
else
{
_bits.Add(key, value);
}
}
get
{
if (_bits.ContainsKey(key))
{
return _bits[key];
}
else
{
return string.Empty;
}
}
}
public int Count()
{
return _bits.Count;
}
public Dictionary<string, stringMyDictionary
{
get
{
return _bits;
}
}
}
}
Nov 16 '07 #4
On Nov 17, 12:06 am, DeveloperX <nntp...@operamail.comwrote:
....
...(watch forline wrap).
A small tool designed to help avoid line wrap.
<http://www.physci.org/twc.jnlp>

--
Andrew T.
PhySci.org
Nov 17 '07 #5

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

Similar topics

8
by: Joseph | last post by:
I am attempting to create a function that will hide all SPANS within an ided DIV ="idMain", then only display one span, but this function gives an error when it gets to elChildElement as being...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
6
by: Daniel Lidström | last post by:
Hi, how do I synchronize (to XML using XmlSerializer) something to this: <Alignments name="Road Project"> <Alignment name="Centerline"> <CoordGeom> <Line staStart="0"> <Start>2000...
9
by: Jon Rea | last post by:
I hav been looking for the last 2 hours on how to do this without much luck. Im going to give a simplifed model of the problem i have. I want a collection class that can holds a series or...
4
by: Michael K. Walter | last post by:
I'd like to create a strongly-typed collection of objects that are indexed by a string value (key is a string). I'd also like to allow users to iterate over the collection using a For-each loop...
2
by: Ian Gore | last post by:
Hi, I'm relatively new to VB.NET so I'd be grateful if someone could point out what I don't understand here... 1) Creating a strongly typed collection by inheriting CollectionBase. This is...
3
by: Dave | last post by:
Please - anyone that can help. I am getting confusing results while trying to expose a collection from a web service. I have a webservice in which a web method accepts a collection as a...
5
by: ffrugone | last post by:
My scenario involves two classes and a database. I have the classes "Broom" and "Closet". I want to use a static method from the "Closet" class to search the database for a matching "Broom". If...
2
by: meyousikmann | last post by:
This will be difficult to explain so bear with me. If anyone is familiar with Tibco Rendezvous and/or Microsoft Messaging, this may make more sense. I've created a hierarchy of objects that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.