diff --git "a/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214.sln" "b/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214.sln" new file mode 100644 index 0000000000000000000000000000000000000000..15f4648b61b8c33085cd1aabc00f0a2cd7290a78 --- /dev/null +++ "b/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "日期和", "日期和\日期和.csproj", "{CD09BEA2-D2C2-4065-A3DC-FE17D058C909}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CD09BEA2-D2C2-4065-A3DC-FE17D058C909}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD09BEA2-D2C2-4065-A3DC-FE17D058C909}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD09BEA2-D2C2-4065-A3DC-FE17D058C909}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD09BEA2-D2C2-4065-A3DC-FE17D058C909}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {350FC1F3-910B-48F5-8543-96D033F6A3A9} + EndGlobalSection +EndGlobal diff --git "a/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214/Program.cs" "b/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3657b2db61d4e7cc17ba320c7e3e9635fa01a4e7 --- /dev/null +++ "b/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214/Program.cs" @@ -0,0 +1,95 @@ +using System; +using System.Linq; +using System.Net.Sockets; +using System.Xml; + +namespace 日期和 +{ + class Program + { + static void Main(string[] args) + { + //日期 + DateTime dt = DateTime.Now; + + Console.WriteLine("现在是{0}年",dt.Year); + Console.WriteLine("现在是{0}年,{1}月",dt.Year,dt.Month); + Console.WriteLine("现在是{0}年,{1}月,{2}日",dt.Year,dt.Month,dt.Day); + + + //Length + string str = Console.ReadLine(); + Console.WriteLine("字符串的长度为:"+ str.Length); + Console.WriteLine("字符串中第一个字符为:"+str[0]); + Console.WriteLine("字符串中最后一个字符为:"+str[str.Length-1]); + + string str1 = Console.ReadLine(); + for (int i = str1.Length - 1; i >= 0; i--) + { + Console.WriteLine(str1[i]); + } + + //IndexOf和LastIndexOf + string str2 = Console.ReadLine(); + if (str2.IndexOf("@")== -1) + { + Console.WriteLine("字符串中没有@"); + } + else + { + Console.WriteLine("字符串中有@,出现的位置是:{0}",str2.IndexOf("@")+1); + } + + string str3 = Console.ReadLine(); + int First = str3.IndexOf("@"); + int Last = str3.LastIndexOf("@"); + if (First != -1) + { + if (First == Last) + { + Console.WriteLine("在此字符串中仅有一个@"); + } + else + { + Console.WriteLine("此字符串中有多个@"); + } + } + else + { + Console.WriteLine("字符串中没哟@"); + } + + //Replace:字符串替换函 + string str4 = Console.ReadLine(); + if(str4.IndexOf(",")!=-1) + { + str4 = str4.Replace(",", "~"); + } + + + // Substring:字符串截取函数 + string str5 = Console.ReadLine(); + int First1 = str5.IndexOf("@"); + str5 = str5.Substring(0, First1); + Console.WriteLine("邮箱中的用户名是:"+str5); + + //insert 插入字符串 + string str6 = Console.ReadLine(); + str = str.Insert(1, "@@@"); + Console.WriteLine("新字符串为:" + str); + + //替换 + string re = Console.ReadLine(); + re = re.Replace(",", "."); + Console.WriteLine(re); + + Console.WriteLine("请输入你的证件号:"); + string man = Console.ReadLine(); + Console.WriteLine("你的出生年月为:"); + man = man.Substring(6,8); + Console.WriteLine(man); + + + } + } +} diff --git "a/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214/\346\227\245\346\234\237\345\222\214.csproj" "b/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214/\346\227\245\346\234\237\345\222\214.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..d453e9a07115e38f587d8e299b4fc2d68f0f4d74 --- /dev/null +++ "b/\345\210\230\346\263\242/\346\227\245\346\234\237\345\222\214/\346\227\245\346\234\237\345\222\214.csproj" @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + +