Back to list
Views:   0
Replies:  0
Archived
,
Reply 1
Hi, I thought I'd take a crack at this.  I'm still learning like you, and this is what I came up with.  It's a small VS 2008 Console project that uses the Strategy Pattern and other cool stuff.  It's probably not exactly what you need but it does what you need without duplicating code.

This was kind of fun.  Three years ago I could never do this.

Here's some code from the attached file example.


class Program
     {
         static void Main(string[] args)
         {

             Console.WriteLine("Enter one of the following values:");
             Console.WriteLine("   Test1, Test2, or Test3");

             // Read the input value
             // Valid values are: Test1, Test2, Test3
             string testType = Console.ReadLine();

             // Convert the string type to the Enum type.
             HistoricalItems key = (HistoricalItems)Enum.Parse(typeof(HistoricalItems), testType.ToLower());

             // Instantiate a new Portfolio context.
             MutualFundsPorfolio portfolio = new MutualFundsPorfolio();

             // Process the selected item type.
             portfolio.Process(key);

             Console.ReadLine();
         }
     }

You can download the file here: http://www.kingwilder.com/downloads/strategyexample.zip - 51KB - VS 2008 project
This zip file contains both VB.Net and C# examples.

I hope it helps.

King Wilder
King Wilder, Jan 04, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas