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 1457
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************ *****@discussio ns.microsoft.co m>
wrote in message news:CF******** *************** ***********@mic rosoft.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. Anyone have that page
ref handy listing the C modules that the pypy team need translated into
python?
|
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 have MS Office 2003. However I don't know which file I need to
reference for the MS Word 11.0 Object Library.
Or what else do I need to install/download from MS to be able to create MS
Office 2003 Projects.
|
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 how do I set which
interface a frame will leave on, assuming I'm sending a raw frame (no
IP address, just the ethernet address).
If I use C, it seems I'm to use the IP_PKTINFO socket options,
send/recv the ancillary messages and set/check the ...
|
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 'About' screen info):
Microsoft Visual Basic.Net
Microsoft. Net Framework 1.1.4322 SP1
| |
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:
public class MyClass : IComparable, IComparer, IEquatable<MyClass>
What do I NEED to implement?
I am consused looking at the documentation. It says that my class needs to
implement IComparer<T> or IComparable<T>???
|
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 Basic?
When I search through Google it seems to me that most of the introduction think that
Visual Basic is pre-installed. But I did not found a Visual Basic compiler on my Win2000 system.
Where can I download the VisualBasic environment for...
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |