Gets the char in a string from a starting position plus the index - CSharp System

CSharp examples for System:Char

Description

Gets the char in a string from a starting position plus the index

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;//from  ww  w  .  jav a 2 s.  co  m

public class Main{
        //Gets the char in a string from a starting position plus the index
        //string, 3, 1 -> n
        public static char CharMid(string input, int startingIndex, int countIndex)
        {
            if (startingIndex + countIndex < input.Length)
            {
                string str = input.Substring(startingIndex + countIndex, 1);
                return str[0];
            }
            return new char();
        }
}

Related Tutorials