Write their own class implements a simple function string class

the using the System;
 the using the System.Collections.Generic;
 the using the System.Linq;
 the using the System.Text;
 the using System.Threading.Tasks; 

namespace string 
{ 
    class stringDG 
    { 
        public   char [] DATE; // is essentially an array of the string, is a character array 
        ///  <Summary> 
        /// to add a class constructor of the object can be evaluated when creating an object, this constructor can be converted into a character string array
         ///  </ Summary> 
        / //  <param name = "Array"> </ param> 
        public stringDG ( char [] Array) 
        { 
            DATE = new new char [array.length]; // determine the length of the string array 
            for ( int I = 0 ; I <array.length; I ++ ) 
            { 
                DATE [I] = Array [I]; 
            } 
        } 
        ///  <Summary> 
        / // constructor stringDg class, the objects are created, the contents of the string class passed
         ///  </ Summary> 
        ///  <param name = "Array"> </ param> 
        public stringDG (stringDG Array) 
        { 
            DATE = new new  char [Array.getLength];
             for ( int I = 0; I <Array.getLength; I ++ ) 
            { 
                DATE [I] = array.date [I]; 
            } 

        } 
        // null constructors 
        public stringDG () 
        { 

        } 
        ///  <Summary> 
        /// Get length of the string
         / //  </ Summary> 
        ///  <param name = "Array"> </ param> 
        ///  <Returns> </ Returns> 
        public  int   a GetLength 
        { 
           GET 
            { 
               return date.Length; 
            } 
        } 
        ///  <Summary> 
        /// 截取字符串
        /// </summary>
        /// <param name="index"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public stringDG SubString(int index,int length)
        {
            char[] str = new char[length];
            int temp = 0;
            for (int i = index; i < index+length; i++)
            {
                str[temp] = date[i];
            }
            return new stringDG(str);
        }
        /// <summary>
        /// 通过下标获取字符
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public char GetValue(int index)
        {
            return date[index];
        }

       
    }
}

 

Guess you like

Origin www.cnblogs.com/zhangyang4674/p/11334203.html