点击目录传送ฅʕ•̫͡•ʔฅ
记录
C#练习题
第二章课后习题
第3、5、6题
3:编写一个控制台应用程序,接收一个长度大于3的字符串,并完成下列功能
using System; //实际上只用到了这一个
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Practice3
{
class Program
{
static void Main(string[] args)
{
//接受一个长度大于3的字符串
string str1;
Console.WriteLine("请输入字符串:");
str1 = Console.ReadLine();
//输出字符串的长度
Console.WriteLine("字符串长度:" + str1.Length);
//输出字符串中第一个出现字母a的位置
int x = str1.IndexOf("a");
Console.WriteLine("第一个出现字母a的位置:" + x);
//字符串序号从零开始编号,在字符串的第3个字符的的前面插入子串"hello",输出新字符串。
string str2 = str1.Insert(2, "hello");
Console.WriteLine("新字符串:" + str2);
//将字符串"hello"替换为"me",输出新字符串
string str3 = str2.Replace("hello", "me");
Console.WriteLine("新字符串:" &