摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/*数组 保存多个值,几乎任意类型都可以声明数组 * int[] nums = {5,3,8}; * 个数和声明数必须一致 * int[] nums = new int[3]; * 使用索引器访问指定编号位置的元素,访问数组元素: nums[0],nums[1].索引从0开始,取到元素的类型就是数组元素的类型,可以数组元素进行赋值 * * foreach循环 * string[] names = {"tom",& 阅读全文
posted @ 2012-02-19 23:11 简单--生活 阅读(283) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/*枚举 *确定数量,确定值的几个取值,东西南北,男妇,上中下 * enum Gender{male,female} * enum QQStatus{online, offline, hiden} * 枚举的用法, QQStatus status = QQStatus.online * 和用字符串比下场 来,用格举的好处就是限定了变量的取值范围,程序处理起来更方便 * */namespace _33enum枚举{ enum ... 阅读全文
posted @ 2012-02-19 22:07 简单--生活 阅读(163) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/*类型转换Cast(*) *把源类型赋值给目标型,两个类型不一致的时候会发生类型转换,a=b,b是源,a是目标 *隐式转换,显示式转换,当目标型一定能满足源类型转换过去后的要求的话就是隐式转换,如果当目标类型不一定能满足源类型转换过去后的要求的话就需要显示转换(自己负责) *把中国人转换为人是隐式转换,把人转换为中国人则是显示式转换 *内存中的数据没有变化,只是不同的视角而已 *byte b=1, int i=1, i=b, b= 阅读全文
posted @ 2012-02-19 21:48 简单--生活 阅读(352) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 循环的中断 * break; 立即终站整个循环 * continue; 立即终止当前循环步骤,进行下一次循环步骤 */namespace _22循环的中断{ class Program { static void Main(string[] args) { //练习1:用while continue实现计算1到100之间的除了被7整除之外的所有整数的和 ... 阅读全文
posted @ 2012-02-19 21:21 简单--生活 阅读(248) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* switch case * 类似于if...else....else if....else 但是离散值的判断 * switch一般都可以用if重写,但是if不一定能用switch重写 * 不要忘了break; C#中的break不写是不行的,除了合并case的情况 * * while循环 只要while后小括号中表达式为true,就不执行大括号中的代码 *///15SwitchCase whilenamespace _15S. 阅读全文
posted @ 2012-02-19 18:41 简单--生活 阅读(242) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _12if{ class Program { static void Main(string[] args) { //作业1: 提示用户输入密码,如果密码是"888888"则提示正确,否则提示错误 Console.WriteLine("请输入密码:"); //问题1,用户输入的是非数字的时候失败 ... 阅读全文
posted @ 2012-02-19 18:11 简单--生活 阅读(327) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 布尔运算 * 相等判断: ==, 不要和=混淆 * WriteLine("{0}",i==1); WriteLine("{0}",i=1); 的区别 * 不等判断!= * 大小比较< > <= >= * 取返: ! * 组合运算: && || */namespace _9布尔运算符{ class Program { static void Main 阅读全文
posted @ 2012-02-19 17:23 简单--生活 阅读(210) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 赋值运符=,让左边变量的值等于右边的计算结果,这就能解释令人不解的i = i+1; * (*)+=,-=, *= /= * i2 = i1++; i2=++i1; * */namespace 赋值运算{ class Program { static void Main(string[] args) { //习题: int a = 10; a++; a=a+a; ... 阅读全文
posted @ 2012-02-19 11:42 简单--生活 阅读(256) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 运算符,表达式 * + - * / % * +可以用作字符串连接,其他不可以 * ++ -- * */namespace _7算述运算符{ class Program { static void Main(string[] args) { //让用户输入两个数,打印出两个数的和 /*Console.WriteLine("请输入数值1:"); ... 阅读全文
posted @ 2012-02-19 11:33 简单--生活 阅读(203) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 变量的命名 * 命名规则: 第一个字符必须是字线或者下划线(_),基后的字符可以是任意个数字,字母,下划线 * 不用全部使用C#的关键字,比如class,nameespace,new void 等,判断方式: VS中亮蓝色的就是关键字 * 这也是类,函数等的命名规则 * 中文变量名(类中,函数名) * C#中建义变量开头用小写 * * */namespace _6变量的命名{ class Program { ... 阅读全文
posted @ 2012-02-19 11:22 简单--生活 阅读(197) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 简单的类型转换 Convert.ToString() ToString() Convert.Toint32(); * */namespace _4Convert类型转换{ class Program { static void Main(string[] args) { Console.WriteLine("请输入第一个字符:"); strin... 阅读全文
posted @ 2012-02-19 11:12 简单--生活 阅读(312) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _2字符串{ class Program { static void Main(string[] args) { //string s = "\"ab\""; //string s = "a\nb"; //n:newline //string s = "a\\b"; //string s... 阅读全文
posted @ 2012-02-19 11:02 简单--生活 阅读(144) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* Virutal studio 是开发工具 * C# 是一种语言C Sharp * .Net Framework是提供函数库类库 * 创建第一个控制台程序并且调试运行 * 为什么要从控制台程序开始? 不要把精力放到表现层,而是把精力放在写代码上, * 无论控制台还是winform还是ASP.net最难的是写代码,而不是拖控件 * 唯一需要学的三条控制台指令,Console.WirteLine:打印输出 * Console.Rea 阅读全文
posted @ 2012-02-19 10:50 简单--生活 阅读(258) 评论(1) 推荐(1) 编辑
简单--生活(CSDN)