国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

String類使用的例子(2)

2019-11-18 15:18:35
字體:
來源:轉載
供稿:網友

  Console.Write("Enter the string array length : ");
string strArr=Console.ReadLine();
int intArr=int.Parse(strArr);
for (int i=0;i<intArr;i++) {
Console.Write("Enter string " + i + " : ");
strTempArr[i]=Console.ReadLine();
}

Console.WriteLine("the Concatenated string : " + String.Concat(strTempArr));
Console.WriteLine("the concatenation of the first two string : " + String.Concat(strTempArr[0],strTempArr[1]));

Console.WriteLine("the concatenation of the first three string : " + String.Concat(strTempArr[0],strTempArr[1],strTempArr[2]));

Console.WriteLine("the concatenation of the first four string : " + String.Concat(strTempArr[0],strTempArr[1],strTempArr[2],strTempArr[3]));

}

PRivate void mtdCopy() {
Console.WriteLine("String.Copy(String str) - > returns a new string with the same value as ‘str‘");
Console.WriteLine("original string : " + objString.str);
Console.Write("enter the string to replace the above one : ");
string strCopy=Console.ReadLine();
objString.str=String.Copy(strCopy);
Console.WriteLine("the string after copying : " + objString.str);
}

private void mtdCopyTo() {
Console.WriteLine("String.CopyTo(int srcIndex,char[] dest,int destIndex,int intCount) - > copies a part of string to another string");

Console.WriteLine("srcIndex -> the start index in the original string from where u want the copy");
Console.WriteLine("dest -> the destination chracter array");
Console.WriteLine("destIndex -> the start index in the destination array to which the characters should be copied");

Console.WriteLine("dest -> the length of characters in the original string to be copied");
Console.WriteLine("Destination string is : " + objString.str);
Console.Write("Enter the source string : ");
string strTmp=Console.ReadLine();
Console.Write("Enter the starting index for source string : ");
string strSrcSt=Console.ReadLine();
int intSrcSt=int.Parse(strSrcSt);
Console.Write("Enter the starting index in the destination string : ");
string strDstSt=Console.ReadLine();
int intDstSt=int.Parse(strDstSt);
Console.Write("Enter the number of characters to be copied from the source string : ");
string strSrcLn=Console.ReadLine();
int intSrcLn=int.Parse(strSrcLn);
chArray=objString.str.ToCharArray();
strTmp.CopyTo(intSrcSt,chArray,intDstSt,intSrcLn);
objString.str=new String(chArray);
Console.WriteLine("The changed string is : " + objString.str);
}

private void mtdEndsWith() {
Console.WriteLine("String.EndsWith(String str) - > this function returns a boolen value, checking whether the parent string ends with ‘str‘");



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富川| 青阳县| 平罗县| 寻甸| 石河子市| 金湖县| 松潘县| 大荔县| 怀宁县| 达孜县| 海丰县| 清河县| 湄潭县| 龙胜| 安康市| 阿瓦提县| 海淀区| 冀州市| 乌拉特中旗| 涞源县| 临邑县| 乾安县| 鹤壁市| 惠东县| 无锡市| 鄂尔多斯市| 德保县| 亚东县| 微博| 鞍山市| 桃园县| 灵丘县| 永宁县| 龙陵县| 会东县| 栾城县| 若尔盖县| 隆回县| 鹤庆县| 彰化市| 耿马|