C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 12-10-2007, 03:56 AM   #1
Registered User
 
Join Date: Nov 2005
Posts: 41
Thumbs up Casting Enumerator?!?

I have implemented a Properties class that may contain name-value pairs. They are stored in a Hashtable. Now I want to implement this function:
Enumerator<string> PropertyNames();

How do I do that? When I do GetEnumerator on the Hashtable inside the Properties class, I get a Enumerator<Hashtable.Keys> back. How do I return Enumerator<string>?

Code:
namespace qwerty 
{

Class Properties
{
private   Hashtable mHashtable = new Hashtable();

public    Enumerator<string>  PropertyNames()
{


}


public AddProp(string Name, string Value)
{
   mHashtable.Add(Name, Value); 
   return;
}




}



}
mdoland is offline   Reply With Quote
Old 12-10-2007, 05:43 AM   #2
Confused
 
Magos's Avatar
 
Join Date: Sep 2001
Location: Sweden
Posts: 3,125
Make your own enumerator class (which implements System.Collections.IEnumerator) which is returned from the properties class. It should have 3 methods: Reset, MoveNext and Current.get. To allow your properties class to be used directly in an foreach statement make sure it implements System.Collections.IEnumerable.
__________________
MagosX.com

Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Magos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Advantages of c++ type casting over c type casting kaibalya2008 C++ Programming 10 05-05-2009 11:09 AM
load gif into program willc0de4food Windows Programming 14 01-11-2006 10:43 AM
casting the system exstracted date into seperate ints bazzano C Programming 1 08-30-2005 12:17 AM
Type casting Lionmane C Programming 28 08-20-2005 02:16 PM
question about casting pointers/other types also?? newbie02 C++ Programming 3 08-07-2003 05:01 AM


All times are GMT -6. The time now is 04:11 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22