Hi
I want to create a rather simple object with a few string attributes
to hold some database user information such as:
public class UserInfo
{
//Basic user information for each user associated with a database.
private string sDbName;
private string sUserName;
.... other stuff....
public string dbName
{
get {...} set{ }
}
public string UserName
{ ........etc.etc....
}
......more stuff
}
There can be many UserInfo objects for each database.
Then, I was thinking another object , say dbUsers, that contains many
UserInfo objects. One dbUsers object for each database. (Maybe now, I
would not need to keep the dbName in the UserInfo object as all
UserInfo objects would always belong to some dbUsers object.
And finally, an object, say AllDbsAndUsers to hold all dbUser
objects.
I would create one dbUser object at a time, populate it with several
UserInfo objects, for a particular db, and then "add" it to the
AllDbsAndUsers object.
To use AllDbsAndUsers I would like to be able to "add" objects, get
objects based on db name, etc...
It will be handy in several situations to be able to use foreach loops
to run through one object, while processing the inner objects.
I am looking at IEnumerable, IEnumerator, IDictionary, DictionaryBase
and Hashtables. I really am not sure where to begin.
Is there also an Interface called Iterator?
What is the basic minimum needed any any object to be able to use a
foreach loop?
Are the requirements different if I want to have an "add" method?
Thanks
Jeff
"I'll get this sooner or later" 3 1443
Check out IList and also CollectionBase
You could always inherit from HashTable (my favourite)
There's a good example in MSDN help files that demonstrates all this.
Can't remember what its called though.
I think it used the "Widget" class....
The minimum requirement to use foreach over an object is that it implements
the IEnumerable inteface http://msdn.microsoft.com/library/de...mberstopic.asp
You can find some foreach info at http://msdn.microsoft.com/library/de...hstatement.asp
Sayed Ibrahim Hashimi www.sedodream.com
"Jeff User" wrote: Hi I want to create a rather simple object with a few string attributes to hold some database user information such as:
public class UserInfo { //Basic user information for each user associated with a database. private string sDbName; private string sUserName; .... other stuff....
public string dbName { get {...} set{ } } public string UserName { ........etc.etc.... } ......more stuff }
There can be many UserInfo objects for each database.
Then, I was thinking another object , say dbUsers, that contains many UserInfo objects. One dbUsers object for each database. (Maybe now, I would not need to keep the dbName in the UserInfo object as all UserInfo objects would always belong to some dbUsers object.
And finally, an object, say AllDbsAndUsers to hold all dbUser objects.
I would create one dbUser object at a time, populate it with several UserInfo objects, for a particular db, and then "add" it to the AllDbsAndUsers object.
To use AllDbsAndUsers I would like to be able to "add" objects, get objects based on db name, etc... It will be handy in several situations to be able to use foreach loops to run through one object, while processing the inner objects.
I am looking at IEnumerable, IEnumerator, IDictionary, DictionaryBase and Hashtables. I really am not sure where to begin. Is there also an Interface called Iterator?
What is the basic minimum needed any any object to be able to use a foreach loop? Are the requirements different if I want to have an "add" method?
Thanks
Jeff "I'll get this sooner or later"
Just a little correction.
The minimum requirements is the object to expose public GetEnumerator method
that returns object exposing all the methods in IEnumerator.
Implementing IEnumerable or IEnumerator is not a must.
However implementing these interfaces is a good idea beacuse it makes type's
documentation clearer and easier to understand. Not implementing the
interfaces on the other hand can be used to improve the performance in a
case of collection of value types.
--
Stoitcho Goutsev (100)
"Sayed Ibrahim Hashimi" <Sa*****************@discussions.microsoft.com>
wrote in message news:CF**********************************@microsof t.com... The minimum requirement to use foreach over an object is that it implements the IEnumerable inteface http://msdn.microsoft.com/library/de...mberstopic.asp You can find some foreach info at http://msdn.microsoft.com/library/de...hstatement.asp
Sayed Ibrahim Hashimi www.sedodream.com "Jeff User" wrote:
Hi I want to create a rather simple object with a few string attributes to hold some database user information such as:
public class UserInfo { //Basic user information for each user associated with a database. private string sDbName; private string sUserName; .... other stuff....
public string dbName { get {...} set{ } } public string UserName { ........etc.etc.... } ......more stuff }
There can be many UserInfo objects for each database.
Then, I was thinking another object , say dbUsers, that contains many UserInfo objects. One dbUsers object for each database. (Maybe now, I would not need to keep the dbName in the UserInfo object as all UserInfo objects would always belong to some dbUsers object.
And finally, an object, say AllDbsAndUsers to hold all dbUser objects.
I would create one dbUser object at a time, populate it with several UserInfo objects, for a particular db, and then "add" it to the AllDbsAndUsers object.
To use AllDbsAndUsers I would like to be able to "add" objects, get objects based on db name, etc... It will be handy in several situations to be able to use foreach loops to run through one object, while processing the inner objects.
I am looking at IEnumerable, IEnumerator, IDictionary, DictionaryBase and Hashtables. I really am not sure where to begin. Is there also an Interface called Iterator?
What is the basic minimum needed any any object to be able to use a foreach loop? Are the requirements different if I want to have an "add" method?
Thanks
Jeff "I'll get this sooner or later" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Caleb Hattingh |
last post by:
Hi all
I saw it on a webpage a few days ago, can't seem to find it again. Tried
a google search for
"pypy needed translate C modules"
but that didn't turn up what I was looking for. ...
|
by: Helene Day |
last post by:
I am trying to access the Word Objects from a .NET project.
I have some sample from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/WordObject.asp
and I...
|
by: John Cho |
last post by:
if i do a friend Testclass operator +(Test class &obj2); it is not
correct because i need two objects?
|
by: Lincoln Yeoh |
last post by:
Hi,
If I have a program listening on 0.0.0.0:(someport) on all interfaces,
how do I know which network interface a broadcast packet is coming in
on - assuming Linux and _many_ interfaces. And...
|
by: jbraly |
last post by:
I am BY NO MEANS a developer or a programmer... I just do tech
purchases for a school system.
A teacher wants about 20 licensse for the following program (He said he
got this info from the...
| |
by: preport |
last post by:
Hopefully someone can clarify some of this for me.
I am confused on what classes I should implement if I want to utilize the
List<>.BinarySearch() and Sort()
My class currently looks like:
...
|
by: Frank Callone |
last post by:
Until now I programmed a lot with C++ and Java. Now I want (have) to do some programming with
Visual Basic. Which software do I need for this ?
Which is the best GUI development tool for Visual...
|
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,...
|
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,...
|
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: 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...
| |
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...
|
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...
|
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...
|
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...
| |