i find this code in a forum
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);
}
}
this code is working, but i dont understand what is "
RightToLeft rtl = Parse<RightToLeft>(rightToLeftText);
and what it does?
also i dont understand
return (T)TypeDescriptor.GetConverter(typeof(T))
.ConvertFromInvariantString(text);)
? what type of format it is , and how it works
plz anyone explain me, i will be grateful.
ALSO my actual problem is i write a object.location as a string in file and read it from file and trying to convert in drawing.point. but my string write as "{X=11,Y=19}"
not like ""11, 19", as code, how can i convert this string to point.
thanx.