///
<summary>
/// 根据字符串对字符串进行分割
/// </summary>
/// <param name="s_value"> 源字符串 </param>
/// <param name="m_value"> 分隔符 </param>
/// <returns></returns>
private string [] SplitByString( string s_value, string m_value)
{
int Lengthofm_value = m_value.Length; // 分隔符的长度
int count = 0 ;
int start = 0 ;
int end = s_value.Length;
int at = 0 ;
int m = 1 ;
while ((start <= end) && (at > - 1 ))
{
count = end - start;
at = s_value.IndexOf(m_value, start, count);
if (at == - 1 ) break ;
// 20071114:将微软示例代码由start = at + 1改为start = at +Lengthofm_value
// 避免出现2个分隔符连续出现产生错误
start = at + Lengthofm_value;
// start = at + 1;
m ++ ;
}
string [] strArray = new string [m];
strArray[ 0 ] = s_value;
if (s_value.IndexOf(m_value) != - 1 )
{
for ( int i = 0 ; i < m; i ++ )
{
// 获取分隔符前面的字符串
if (i != m - 1 )
{
strArray[i] = s_value.Substring( 0 ,s_value.IndexOf(m_value));
s_value = s_value.Substring(m_value.Length + s_value.IndexOf(m_value));
}
// 最后一个被分隔字符
else
{
strArray[i] = s_value;
}
}
}
return strArray;
}
/// 根据字符串对字符串进行分割
/// </summary>
/// <param name="s_value"> 源字符串 </param>
/// <param name="m_value"> 分隔符 </param>
/// <returns></returns>
private string [] SplitByString( string s_value, string m_value)
{
int Lengthofm_value = m_value.Length; // 分隔符的长度
int count = 0 ;
int start = 0 ;
int end = s_value.Length;
int at = 0 ;
int m = 1 ;
while ((start <= end) && (at > - 1 ))
{
count = end - start;
at = s_value.IndexOf(m_value, start, count);
if (at == - 1 ) break ;
// 20071114:将微软示例代码由start = at + 1改为start = at +Lengthofm_value
// 避免出现2个分隔符连续出现产生错误
start = at + Lengthofm_value;
// start = at + 1;
m ++ ;
}
string [] strArray = new string [m];
strArray[ 0 ] = s_value;
if (s_value.IndexOf(m_value) != - 1 )
{
for ( int i = 0 ; i < m; i ++ )
{
// 获取分隔符前面的字符串
if (i != m - 1 )
{
strArray[i] = s_value.Substring( 0 ,s_value.IndexOf(m_value));
s_value = s_value.Substring(m_value.Length + s_value.IndexOf(m_value));
}
// 最后一个被分隔字符
else
{
strArray[i] = s_value;
}
}
}
return strArray;
}