String类使用的例子(3)

王朝other·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

if ("first"==strFL)

Console.WriteLine("The index value returned is : "+ objString.str.IndexOfAny(c,intStart));

else

Console.WriteLine("The index value returned is : "+ objString.str.LastIndexOfAny(c,intStart));

break;

case 3:

Console.Write("Enter the string for the character array :");

strChar=Console.ReadLine();

c=strChar.ToCharArray();

Console.Write("Enter the starting Index for search :");

intStart=int.Parse(Console.ReadLine());

Console.Write("Enter the number of characters to searc :");

intCount=int.Parse(Console.ReadLine());

if ("first"==strFL)

Console.WriteLine("The index value returned is : "+ objString.str.IndexOfAny(c,intStart,intCount));

else

Console.WriteLine("The index value returned is : "+ objString.str.LastIndexOfAny(c,intStart,intCount));

break;

case 4:

blnStay=false;

break;

}

if (blnStay)

mtdIndexAnyImpl(strValue,strFL);

}

private void mtdInsert() {

Console.WriteLine("String.Insert(int index,string str) - > this functions returns the original string with ‘str‘ inserted at ‘index‘");

Console.WriteLine("the original string : " + objString.str);

Console.Write("Enter the string to be inserted : ");

string strTmp=Console.ReadLine();

Console.Write("Enter the position where it has to be inserted :");

int intTmp=int.Parse(Console.ReadLine());

objString.str=objString.str.Insert(intTmp,strTmp);

Console.WriteLine("the modified string : " + objString.str);

}

private void mtdJoin() {

string[] s=;

Console.WriteLine("1.String.Join(string str,string[] strarr) - > this functions joins the string arrays using ‘str‘");

Console.WriteLine("2.String.Join(string str,string[] strarr,int i,int j) - > this functions joins the string arrays using ‘str‘ starting from the ‘i‘ th array element and ‘j‘ number of elements after it. ");

Console.Write("Enter your choice :");

string strChoice=Console.ReadLine();

if ("1"==strChoice) {

Console.WriteLine("The string array is :str[0]=‘welcome‘,str[1]=‘to‘,str[2]=‘the‘,str[3]=‘world‘,str[4]=‘of‘,str[5]=‘c#‘");

Console.Write("Enter the string with which to join : ");

string strTmp=Console.ReadLine();

Console.WriteLine("The joint string is : " + String.Join(strTmp,s));

}

else {

Console.WriteLine("The string array is :str[0]=‘welcome‘,str[1]=‘to‘,str[2]=‘the‘,str[3]=‘world‘,str[4]=‘of‘,str[5]=‘c#‘");

Console.Write("Enter the string with which to join : ");

string strTmp=Console.ReadLine();

Console.Write("Enter the starting index of the array : ");

int intStart=int.Parse(Console.ReadLine());

Console.Write("Enter the number of elements to join :" );

int intCount=int.Parse(Console.ReadLine());

Console.WriteLine("The joint string is : " + String.Join(strTmp,s,intStart,intCount));

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航