|
Mailing Lists
|
Home /
Groups /
.NET Technical Talk (Net-Talk)
C## equivalent of evaluate()?
> Semantics question.Tom Donovan 08/01/06 05:54 A Hummm...Nathan Strutz 08/01/06 08:38 P If you're in C# 2.0, you can use generics.Phillip Holmes 08/01/06 10:12 P Hummm... I wonder if your data structure is a bit off. Instead of an array of strings and string_bool values, perhaps you should do one of a couple things: 1) Have an array of strings, then a corresponding array of booleans 2) Have a hashTable instead of an arrayList. If you know all the strings by name, why not use that. It's like using a struct in CF (if you've used structures before). It's sort of like an array, except that you don't index them by number, but by name (the string). Then the strings would be boolean values... hmm. let's visualize: Hashtable stuff = new Hashtable(); stuff.add("mystring1", true); stuff.add("mystring2", false); MessageBox.show(stuff.mystring1.toString()); // will pop up the message "true" And of course you can loop over it with a foreach loop because it's enumerable. Now i'm not 100% on this, but it *should* work ;) Hope that helped. -nathan strutz http://www.dopefly.com/ ----- Excess quoted text cut - see Original Post for more ----- If you're in C# 2.0, you can use generics. using System; using System.Collections.Generic; using System.Text; namespace genericsDemo { class Program { static void Main(string[] args) { // using the List collection class List<widget> Widgets = new List<widget>(); Widgets.Add(new Widget("tin-foil hat")); Widgets.Add(new Widget("European swallow")); Widgets.Add(new Widget("African swallow")); Widgets.Add(new Widget(1)); foreach (Widget it in Widgets) Console.WriteLine(it.WidgetName); // give a pause to review your good work Console.Readline("hit any key to... blah blah blah"); } } public class Widget { private object _widgetName = ""; public object WidgetName { get { return _widgetName; } set { _widgetName = value; } } // constructor that takes an object argument public Widget(object widgetName) { this._widgetName = widgetName; } } } Warmest Regards, Phillip B. Holmes http://phillipholmes.com 214-995-6175 (cell) ==================> Hummm... I wonder if your data structure is a bit off. -- Internal Virus Database is out-of-date. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: 7/17/2006
|
May 25, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||