随笔分类 - C#
摘要:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.IO.Port
阅读全文
摘要:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO.Ports; using Sys
阅读全文
摘要:1, 拖入计时器timer1 private void Form1_Load(object sender, EventArgs e) { timer1.Interval = 1000;//设置计时器间隔时间, 单位ms timer1.Start();//启动计时器 } private void ti
阅读全文
摘要:1, 新建窗口frm_Login using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Li
阅读全文
摘要:/*哈希表,表示键/值对的集合,这些键/值对根据键的哈希代码进行组织。它的每个元素都是一个存储在DictionaryEntry对象中的键/值对。键不能为空引用,但值可以。哈希表的构造函数有多种,这里介绍两种最常用的。*/ //(1)使用默认的初始容量、加载因子、哈希代码提供程序和比较器来初始化Has
阅读全文
摘要:1, ArrayList集合的遍历与数组类似,都可以使用foreach语句 string[] str1 = { "a", "b", "c" ,"d","e","f"}; ArrayList List = new ArrayList(str1); foreach (var item in List)
阅读全文
摘要:1 Clear()方法 Clear()方法用来从ArrayList中移除所有元素,语法格式如下。 string[] str1 = { "a", "b", "c" }; ArrayList List = new ArrayList(str1); List.Clear(); 2 Remove()方法 R
阅读全文
摘要:ArrayList提供了3个构造器,通过这3个构造器可以有3种声明方式。 (1)默认构造器,会以默认大小(16位)初始化内部数组。构造器格式如下。 ArrayList List = new ArrayList();//实例化一个ArrayList,命名为List; for (int i = 0; i
阅读全文
摘要://数组的遍历: foreach /*说明:foreach循环不必像for循环那样要预先知道数组或集合的细节,确定循环次数和通过下标索引查找当前对象,因此当集合容量大,维数高时能极大地提升效率。但foreach循环里不能随便添加或者删除元素,因此需要更改集合内容时不能使用foreach语句。*/ i
阅读全文
摘要://创建一个控制台应用程序,使用二维数组存储火车票信息,输入车次和姓名后,模拟预订火车票功能,代码如下: string train = "", destination = "", StartTime = "";//声明3个字符串: 车次,车次信息, 出发时间; string[] 标题 = { "车次
阅读全文
摘要:一维数组的声明: int[] int1=new int[3]; //默认初始化值均为0;一维数组两种初始化方式 : ①int[] int1={1,2,3,4}] ②: int[] int1=new int[]{1,2,4,4}; 二维数组的声明: int[,] int1=new int[2,4];二
阅读全文
摘要://创建一个控制台应用程序,定义一个int型的一维数组,将各月的天数输出,程序代码如下 int[] intDays = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; for (int i = 0; i < 12; i++)
阅读全文
摘要://创建一个控制台应用程序,在Mian()方法中编写如下代码,验证字符串操作和可变字符串操作的执行效率。 string str = ""; long longStartTime = DateTime.Now.Millisecond; for (int i = 0; i < 10000; i++) {
阅读全文
摘要://StringBuilder的定义及相关操作 int int1 = 100; StringBuilder str1 = new StringBuilder("哈哈哈,", 100); str1.Append("你变了"); //Append函数 Console.WriteLine(str1); s
阅读全文
摘要:static void Main(string[] args) { //截取字符串 string str1 = "ABCDEFGHIJKLMN"; string str2 = str1.Substring(0, 4);//从0位开始截取,共截取4位; Console.WriteLine(str2);
阅读全文
摘要:static void Main(string[] arg) { //日期时间的格式化 /*练习: 获取系统的当前日期时间,然后使用格式规范D将日期时间格式化为“YYYY年MM月dd日”的格式,代码如下*/ DateTime dt = DateTime.Now; string str1 = stri
阅读全文
摘要:static void Main(string[] arg) { /*数值类型的格式化*/ //输出金额 Console.WriteLine("今天我赚了{0:C}元", 120); //输出科学计数法 Console.WriteLine("12000.1用科学计数法表示是{0:E};", 1200
阅读全文
摘要:static void Main(string[] arg) { int int1 = 0; int int2 = 0; int int3 = 0; string str1 = "adf"; string str2 = "adf"; string str3 = "Adf"; string str4
阅读全文

浙公网安备 33010602011771号