Copies an array of chars obtained from a String into a specified array of chars - CSharp System

CSharp examples for System:Char

Description

Copies an array of chars obtained from a String into a specified array of chars

Demo Code


using System.Text;
using System.Collections;
using System;/*from   w ww. j a  va2 s  . c o  m*/

public class Main{
        /*******************************/

    /// <summary>
    /// Copies an array of chars obtained from a String into a specified array of chars
    /// </summary>
    /// <param name="sourceString">The String to get the chars from</param>
    /// <param name="sourceStart">Position of the String to start getting the chars</param>
    /// <param name="sourceEnd">Position of the String to end getting the chars</param>
    /// <param name="destinationArray">Array to return the chars</param>
    /// <param name="destinationStart">Position of the destination array of chars to start storing the chars</param>
    /// <returns>An array of chars</returns>
    public static void GetCharsFromString(String sourceString, int sourceStart, int sourceEnd, char[] destinationArray,
                                          int destinationStart)
    {
      int sourceCounter;
      int destinationCounter;
      sourceCounter = sourceStart;
      destinationCounter = destinationStart;
      while (sourceCounter < sourceEnd)
      {
        destinationArray[destinationCounter] = sourceString[sourceCounter];
        sourceCounter++;
        destinationCounter++;
      }
    }
}

Related Tutorials