上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 49 下一页
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 属性 * 惯用法,属性开头字母大写,字段开头字母小写 * 只用set或者只有get就可以定义只读或者只写属性(只写的不常见) * 可以为set get设置访问经别 * (.Net3.x)简化set get; public int Age{ get; set; } 适合于set, get 中凤有特殊死搏斗逻辑代码的情况 * * 字段和属性的区别是什么?属性看似字段,不是字段,可以地非法值控制,可以设置只读 * set get块. 阅读全文
posted @ 2012-02-23 22:48 简单--生活 阅读(223) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 成员访问级别 * 字段,方法,属性都可以叫做类的成员,它们都需要定义访问级别,访问级别的用处在于控制成员在哪些些地方可以被访问,这样达到面向对像中"封装"的目的 * * 几个访问级别: public(任何地访都可以访问) private:默认级别,只能由本类中的成员访问 * 还有intemal, protected两个级别,以后会讲 */namespace _2面向对像简介{ class Program { 阅读全文
posted @ 2012-02-23 22:31 简单--生活 阅读(169) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 面向对像概念(*) * 面向对像不是取代面向过程的 * 类,对象。"人"是类,"张三"是"人"这个类的对像,类是抽像的,对象是的,按钮就是类,某个按钮就是对像,对像可以叫做类的实例 * 类就像int, 对像就像10,字段(和类相关的变量),字段就是类的状态,人这个是类的姓名,年龄,身高等字段,类不占内存,对像才占内存 * * 方法,方法就是类能够够执行的动作,比如间好 阅读全文
posted @ 2012-02-23 22:19 简单--生活 阅读(328) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _49_ref_out{ class Program { static void Main(string[] args) { /* 函数的ref out参数 * 函数参数默认的值传递的,也就是"复制一份",例子: * int age = 20; * Int Age(age); ... 阅读全文
posted @ 2012-02-21 23:32 简单--生活 阅读(212) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* * 字符串的处理 */namespace _42字符串基础{ class Program { static void Main(string[] args) { //C#中的单个字符用单引号包含就是char类型,('a'),单引号中放且只能放一个字符 //char a = 'a'; //char b = 'aaa'; ... 阅读全文
posted @ 2012-02-21 00:05 简单--生活 阅读(334) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 函数 * 孙数就是将一堆代码进生重用的一种机制,函数就是一段代码,这段代码可能有输入的值,可能会返回值,一个函数就像一个专门做这件事的人,我们调用它来作一些事情,它可能需要我们提供一些数据给它 * 它执行完成后可能会有一些执行结果给我们,要求的数据就叫参数,返回的执行结果就是返回值 * Console.ReadLine就是一个有返回结果的函数 * Console.WriteLine("Hello")就是一个 阅读全文
posted @ 2012-02-20 22:10 简单--生活 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 49 下一页
简单--生活(CSDN)