上一页 1 ··· 8 9 10 11 12
摘要: 常用字段类型bit(0和1),datetime,int,varchar,nvarchar(可能含有中文用nvarchar)Varchar,nvarchar和char(n)的区别char(n)不足长度n的部分用空格填充。SQL语句中,字符串用单引号。SQL语句大小写不敏感。不敏感是指SQL的关键字,字符串值还是敏感的。简单的INSERT语句 INSERT INTO Person(Id,Name,Age) VALUES(1,’Jim’,20)常用int和uniqueidentifier做主键数据类型标识规范:自动给主键填充值。将字段“是标识列”设置为“是”,一个表只能有一个标识列Guid算法是一种 阅读全文
posted @ 2011-08-24 18:36 唐小喵 阅读(451) 评论(0) 推荐(0) 编辑
摘要: 索引器namespace 索引器{ class Program { static void Main(string[] args) { Person p1 = new Person(); p1[1] = "小明"; Console.WriteLine(p1[1] + p1[2]); Console.ReadKey(); } } public class Person { private string firstName = "大毛"; private string secondName = "二毛"; //下面这个就是索引器 publ 阅读全文
posted @ 2011-08-24 18:34 唐小喵 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 异常using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 异常{ class Program { static void Main(string[] args) { try { int i = Convert.ToInt32("abc"); } catch (Exception e) { Console.WriteLine("发生错误:" + e.Message + "\n异常堆栈:" + e.StackT 阅读全文
posted @ 2011-08-24 18:33 唐小喵 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 属性开头大写,字段开头小写namespace 属性{ class Program { static void Main(string[] args) { person p = new person(); p.Age = 30; Console.WriteLine(p.Age); person1 p1 = new person1(); Console.WriteLine(p1.Age);//自动赋初值0 Console.ReadKey(); } } class person { private int age; public int Age //这就是属性。拥有set和get Age并没有保存数 阅读全文
posted @ 2011-08-24 18:32 唐小喵 阅读(183) 评论(0) 推荐(0) 编辑
摘要: namespace refout参数{ class Program { static void Main(string[] args) { int age = 20; int age1 = 20; IncAge(ref age);//函数调用也要加ref IncAge1(out age1);//这里用out时,参数不需要初始化,函数里会把参数当做没初始化来用。把参数扔进去就行了,返回处理后的值。 Console.WriteLine(age); Console.ReadKey(); } static void IncAge(ref int age) //传址(引用)要加ref { age++; 阅读全文
posted @ 2011-08-24 18:30 唐小喵 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 字符串字符串可以当做字符数组处理,但是只能读,不能用数组的形式修改其中一位。如果非要修改,则必须用s.ToCharArray()方法得到字符串的字符数组。namespace 字符串中字符修改{ class Program { static void Main(string[] args) { string s1 = "hello"; char[] s2 = s1.ToCharArray();//将字符串转成字符数组以进行字符的修改 s2[2] = 'y'; string s3 = new string(s2);//调用构造函数new string (char 阅读全文
posted @ 2011-08-24 18:29 唐小喵 阅读(372) 评论(0) 推荐(0) 编辑
摘要: 函数 都以static开头namespace 可变参数的函数{ class Program { static void Main(string[] args) { string[] names = { "Coco", "Lily", "Lucy" }; string country = "China"; VFunc(names); VFunc(country); SayHello("Tom", "张大虎", "狗剩"); Console.ReadKey() 阅读全文
posted @ 2011-08-24 18:27 唐小喵 阅读(201) 评论(0) 推荐(0) 编辑
摘要: @:表示后面的“\”不表示转义字符。转义符只针对在代码中直接写出的字符串。不针对从控制台读入的字符串。控制台读入什么就打印什么,不会转义。简单的类型转换Console.WriteLine("请输入一个数字:"); String s1 = Console.ReadLine(); //不能用int来接收 int i1 = Convert.ToInt32(s1); Console.WriteLine(i1);手机号或者密码中的数字只是看起来像数字。其实是字符串。Cast 类型转换不能在int和string之间进行强制类型转换。只能用convert转换。Enum 枚举的好处在于限定 阅读全文
posted @ 2011-08-24 18:26 唐小喵 阅读(416) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12
点击右上角即可分享
微信分享提示