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);
}
} |
|