- 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 src;
- else return src.Substring(0,src.IndexOf(","));
- }
-
-
-
-
-
-
- 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;
- }
-
-
-
-
-
- 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());
- }
- }
- }
-
vp5HTML5中文学习网 - HTML5先行者学习网vp5HTML5中文学习网 - HTML5先行者学习网