Get UShort Element from XElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Get UShort Element from XElement

Demo Code


using System.Xml.Linq;
using System;//from w ww. j  av  a  2 s  .  com

public class Main{
        public static ushort GetUShortElem(this XElement elem, string name)
        {
            ushort.TryParse(elem.GetElemValue(name), out var v);
            return v;
        }
        public static string GetElemValue(this XElement elem, string elemName)
        {
            return elem.Element(elemName)?.Value;
        }
}

Related Tutorials