摘要: 例:将用户输入的一句英文:i have a dog中的每个单词首字母转换为大写 string s = "i have a dog"; string[] strArray = s.Split(' '); string result = "";//定义一个空字符串 foreach (string c i 阅读全文
posted @ 2019-01-28 18:06 豆皮没有豆 阅读(385) 评论(0) 推荐(0)
摘要: 例: 在聊天室中经常遇到屏蔽脏话功能,完成当用户输入一句话中带有“sb”,则将“sb”替换成“**” Console.WriteLine("请输入一句带有sb的话:"); string rep = Console.ReadLine(); string a = rep.Replace("sb", "* 阅读全文
posted @ 2019-01-28 17:54 豆皮没有豆 阅读(1037) 评论(0) 推荐(0)
摘要: 例:接受用户输入的邮箱地址,输出邮箱地址的用户名与域名 Console.WriteLine("请输入你的邮箱地址:"); string Meil = Console.ReadLine(); string[] meil = Meil.Split(new char[] { '@' }); Console 阅读全文
posted @ 2019-01-28 17:47 豆皮没有豆 阅读(354) 评论(0) 推荐(0)
摘要: //方法一 Console.WriteLine("请输入:"); string str = Console.ReadLine(); char[] str2 = str.ToCharArray(); for (int i = str2.Length-1; i >=0; i--) { Console.W 阅读全文
posted @ 2019-01-28 17:35 豆皮没有豆 阅读(426) 评论(0) 推荐(0)
摘要: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _01_方法的创建_计算机 { class Pr 阅读全文
posted @ 2019-01-28 16:53 豆皮没有豆 阅读(162) 评论(0) 推荐(0)
摘要: 将一个字符串数组的元素顺序进行反转。{“我”,“是”,“中国人”} 最终结果{“中国人”,“是”,“我”} //方法一 List<string> str = new List<string>() { "我", "是", "中国人" }; str.Reverse(); for (int i = 0; 阅读全文
posted @ 2019-01-28 16:38 豆皮没有豆 阅读(468) 评论(0) 推荐(0)
摘要: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System 阅读全文
posted @ 2019-01-28 16:31 豆皮没有豆 阅读(246) 评论(0) 推荐(0)
摘要: while (true) { Random r = new Random(); int[] array = new int[8]; int[] arr = new int[4]; for (int i = 0; i < arr.Length; i++) { arr[i] = r.Next(1,21) 阅读全文
posted @ 2019-01-28 16:20 豆皮没有豆 阅读(280) 评论(0) 推荐(0)
摘要: 口诀: N 个数字来排队,两两相比小靠前。 ​ 外层循环 N-1,内层循环 N-1-i。 案例:定义一个数组,输出后从大到小排列 using System; using System.Collections.Generic; using System.Linq; using System.Text; 阅读全文
posted @ 2019-01-28 16:11 豆皮没有豆 阅读(329) 评论(0) 推荐(0)
摘要: 注:以下代码皆在控制台输出(控制台应用程序) 数组 数组是一个存储相同类型元素的固定大小的顺序集合。数组是用来存储数据的集合,通常认为数组是一个同一类型变量的集合。 初始化数组 声明一个数组不会在内存中初始化数组。当初始化数组变量时,您可以赋值给数组。数组是一个引用类型,所以您需要使用 new 关键 阅读全文
posted @ 2019-01-28 16:07 豆皮没有豆 阅读(1929) 评论(0) 推荐(0)