Contains Roman Numerals - CSharp System

CSharp examples for System:String Contain

Description

Contains Roman Numerals

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;// w w w. j  a va 2  s. co  m

public class Main{
        public static bool ContainsRomanNumerals(string searchText)
        {
            StringBuilder sb = new StringBuilder();
            String C3 = searchText.Trim();
            sb.Append(C3 + " ");
            String sText = sb.ToString().ToLower();
            String[] rNumbers = {" i", " ii", " iii", " iv", " v", " vi", " vii", " viii", " ix", " x",
                               " xi", " xii", " xiii", " xiv", " xv", " xvi", " xvii", " xviii", " xix", " xx"};
            bool rNumerals = false;
            foreach (string s in rNumbers)
            {
                if (!sText.Contains(s)) continue;
                rNumerals = true;
                break;
            }
            return rNumerals;
        }
}

Related Tutorials