Read Byte from XAttribute - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Read Byte from XAttribute

Demo Code


using System.Xml.Serialization;
using System.Xml.Linq;
using System.Xml;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using System.IO;//from ww w.  ja  v  a 2 s.  c o  m
using System.Globalization;
using System;

public class Main{
        public static byte ReadByte(XAttribute attr)
        {
            if (attr == null)
                return 0;

            byte i;
            if (byte.TryParse(attr.Value, out i))
            {
                return i;
            }
            else
            {
                return 0;
            }
        }
}

Related Tutorials