CSharp - Essential Types XmlConvert Type

Introduction

To format and parse with data from or for an XML file, use XmlConvert from System.Xml namespace.

The methods in XmlConvert handle the XML formatting without needing special format strings.

For instance, true in XML is "true" and not "True".

The formatting methods in XmlConvert have overloaded ToString methods.

The parsing methods are called ToBoolean, ToDateTime, and so on.

For example:

Demo

using System;
using System.Xml;

class MainClass/*from w w w  .  j a v  a  2s  . com*/
{
    public static void Main(string[] args)
    {
        string s = XmlConvert.ToString(true);
        bool isTrue = XmlConvert.ToBoolean(s);

        Console.WriteLine(s);
        Console.WriteLine(isTrue);

    }
}

Result