Parse Point from String - CSharp System.Xml

CSharp examples for System.Xml:XML String

Description

Parse Point from String

Demo Code


using System.Text;
using System.Reflection;
using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System.Net;
using System.Drawing;
using System;//from   w  ww .  j a  v  a  2  s  .  c o m

public class Main{
        /// <summary>
      /// 
      /// </summary>
      /// <param name="value"></param>
      /// <returns></returns>
      private static Point ParsePoint(string value)
      {
         string[] values = value.Split(DELIMITERS);
         if (values.Length != 2)
         {
            throw new InvalidCastException("Could not parse point");
         }

         try
         {
            int x = int.Parse(values[0].Trim());
            int y = int.Parse(values[1].Trim());

            return new Point(x, y);
         }
         catch (Exception ex)
         {
            throw new InvalidCastException("Could not parse point", ex);
         }
      }
}

Related Tutorials