Another way?

Aldo Liaks replied to sundar k at 11-May-08 04:17

Sundar,

Marc Gravell suggest this (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3323655&SiteID=1&mode=1):

I am studying it...

---------------------------------------------------------

Here is a reusable approach, suitable for your usage (based on this and your other post) - you could perhaps move the lookup into the method too, so you pass in just the key ("tabControl1.Location") and do the rmLanguage etc inside...

using System.ComponentModel;

using System.Drawing;

using System.Windows.Forms;

static class Program

{

static void Main()

{

string pointText = "11, 19",

rightToLeftText = "Inherit";

Point point = Parse<Point>(pointText);

RightToLeft rtl = Parse<RightToLeft>(rightToLeftText);

}

static T Parse<T>(string text)

{

// might need ConvertFromString

// (rather than Invariant)

return (T)TypeDescriptor.GetConverter(typeof(T))

.ConvertFromInvariantString(text);

}

}


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  C# 3.0 - Converting string / object to System.Drawing.Point - Aldo Liaks  11-May-08 01:09 1:09:06 AM
      Try - sundar k  11-May-08 03:00 3:00:16 AM
          It WORKS - Aldo Liaks  11-May-08 04:10 4:10:08 AM
          Another way? - Aldo Liaks  11-May-08 04:17 4:17:52 AM
          Convert to System.Drawing.SystemColors.Window - Aldo Liaks  11-May-08 07:43 7:43:30 AM
              System.Drawing.Color - sundar k  11-May-08 11:22 11:22:25 AM
                  Nice - Aldo Liaks  12-May-08 02:45 2:45:30 AM
      See more - Rave Rasaiyah  11-May-08 09:25 9:25:26 PM
          Sounds logic... - Aldo Liaks  12-May-08 02:11 2:11:38 AM
View Posts