日期:2013-01-14  浏览次数:20554 次

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={"welcome","to","the","world","of","c#"};
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));

}
}

private void mtdLastIndex() {
Console.WriteLine("String.LastIndexOf() - > this returns the index of the last occurence of a charcter or string in the given string.");

Console.WriteLine("The search of the string stops when the required value is founds or proceedes until the beginning of the string has been reached");

Console.WriteLine("It returns the index if the value is found or '-1' if not found.");
mtdIndexImpl("LastIndex","last");

}

private void mtdLastIndexAny() {
Console.WriteLine("String.La