摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 聊天机器人_面向对象{ class Program { static void Main(string[] args) { person p = new person(); p.Name = "bobi"; p.Eat(5); p.live = true; p.Sa... 阅读全文
posted @ 2011-04-06 22:07 Bruce.陈 阅读(313) 评论(0) 推荐(0)
摘要: 学习了 传智播客 聊天机器人的原理,自己写了个聊天机器人using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 控制台基础联系{ class Program { static void Main(string[] args) { Console.WriteLine("你好!我是机器人"); int Fulllevel = 5;//设置饥饿指数 while (tru... 阅读全文
posted @ 2011-04-06 22:03 Bruce.陈 阅读(429) 评论(0) 推荐(0)
摘要: 面向对象的C#类的概念private:表明的类的封装性,外界不能访问,内部函数可以对它进行处理。字段不能用public ,这样破坏了类的封装性。属性的概念。属性大写字母开头,字段小写开头private int age;public int Age{get;set};等价于public int Age{ set{age=value}; get{return age};}Static 的静态成员,不需要实例就可以使用。体会~~~Static class help{ public Static void read() { console.writeline("让我来帮助你"); 阅读全文
posted @ 2011-04-06 21:55 Bruce.陈 阅读(127) 评论(0) 推荐(0)
摘要: 类型转换有两种 Cast,Convert。Cast 为同类型的隐式转换(int)Number;Convert 为类型的转变:Convert.ToInt32();Convert.ToString() 用于不同类型的转换;例:String str=Console.ReadLine();int Int_str=Convert.ToInt32(str);数组:int[] values={30,20,50};values.length 等用法。。。。int []nums=new int[3];int []nums=new int[3]{20,30,50};Foreach用法:试用与String数组的输出 阅读全文
posted @ 2011-04-06 21:43 Bruce.陈 阅读(678) 评论(0) 推荐(0)
摘要: 觉得有必要了解下C#语言基础。要盖大房子,没地基确实不行。不是空中楼阁~Console.WriteLine("你好,我是bobi");可以说是最常用的输出语句,当然,里面主要是用来输出值的。可是是常量,也可以是变量,管他,就是输出值。Console.WriteLine() ;要输出多个值的时候,最好是用占位符的方法。不容易出错,而且清晰。。例:Console.WriteLine("{0}+{1}={2}",i1,i2,i3); //假设i1=1;i2=3。那么输出结果就是:1+2=3; 体会到了占位符的好处了吧。可以很清楚的替我们表达程序结构。类似的用法 阅读全文
posted @ 2011-04-06 21:17 Bruce.陈 阅读(196) 评论(0) 推荐(0)