- Namespace Tools.module
- {
- public class Tools
- {
- Public Tools ()
- {
- }
- public static string Getstrfromstr (String Src,int Index)
- {
- if (src. IndexOf (",") ==0) src = src. Remove (0,1);
- for (int i=0;i<index;i++)
- {
- src = src. Remove (0,1+SRC. IndexOf (","));
- }
- if (src. IndexOf (",") <0) return to SRC;
- else return SRC. Substring (0,SRC. IndexOf (","));
- }
- <summary>
- Calculates where a character should be located in an ascending sort string.
- </summary>
- <param name= "src" > string </param>
- <param name= "C" > Character </param>
- <returns> where the character should be located </returns>
- public static int Getthesortedindex (string Str,char c)
- {
- int ilength = str. Length;
- if (Ilength = = 0) return 0;
- if (ilength = = 1 && str[0] >= c) return 0;
- else if (ilength = = 1 && str[0] < C) return 1;
- int index = ILENGTH/2;
- if (str[index]>c)
- {
- return Getthesortedindex (str. Substring (0,index), c);
- }
- else if (str[index]<c)
- {
- return Index+1+getthesortedindex (str. Substring (index+1,ilength-index-1), c);
- }
- Else
- return index;
- }
- <summary>
- Inserts a character into a string in ascending order
- </summary>
- <param name= "C" > characters to insert </param>
- <param name= "str" > Purpose string </param>
- public static void Insertcharintosortedstring (char c,ref string str)
- {
- if (Str==null str. length==0)
- {
- Str=c.tostring ();
- Return
- }
- for (int i=0;i<str. length;i++)
- {
- if (str[i]==c) return;
- }
- int index = Getthesortedindex (STR,C);
- str = str. Insert (Index,c.tostring ());
- }
- }
- }