
学习笔记
xhccom
这个作者很懒,什么都没留下…
展开
-
2012.6.3显示接口枚举,结构体
static void Main(string[] args) { //显示接口后,只能通过接口来调用 //普通类是调不到的 B b = new B(); b.AA(); A a = new B(); a.AA();原创 2012-06-04 19:21:17 · 351 阅读 · 0 评论 -
2012.6.11XmlDocument xpath
XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(@"c:\test.xml"); XmlNodeList nodeList = xmldoc.SelectNodes("//items[@name=\"520link\"]"); foreach (XmlNode it原创 2012-06-11 21:21:35 · 265 阅读 · 0 评论 -
2012.6.12 .net 反射
using System.Reflection;反射就是动态加载程序集的元数据 反射有两种方式第一种直接 把对像反射Type t=Typeof(对像) 第二种从程序集加载Assembly asm = Assembly.LoadFile(path);得到是一个集合List li = new List(); li = asm.GetTypes().T原创 2012-06-12 23:08:35 · 469 阅读 · 0 评论 -
2012.6.12 .net自定义xml序列化及自定义特性
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Xml.Linq;using System.IO;using System.Xml.Serialization;using System.Reflection;namespace 自定义xml序原创 2012-06-13 18:24:50 · 719 阅读 · 0 评论 -
2012.6.11 .net深拷贝和浅拷贝
定义不管是深拷贝和浅拷贝 都是两个不同的对象 什么是深拷贝对像中的引用类型,在堆中是指向了两个不同的地方 什么是浅拷贝对像中的引用类型,在堆中是指向了两个相同的地方using System.Runtime.Serialization.Formatters.Binary; #region 浅拷贝 //Person p1 = new Pers原创 2012-06-11 21:28:51 · 1654 阅读 · 0 评论 -
.net隐式类型转换
class Program { static void Main(string[] args) { //显示转换 //Person p1 = (Person)10; //隐式类型转换 //Person p = 10; // Co原创 2012-06-15 20:10:10 · 803 阅读 · 0 评论 -
数据库 基本sql应用
创建表create table x( id int identity(1,1) primary key,)drop table x创建数据库create database schoolon primary( name='school', size=10mb, filename='c:\school.mdf')log on( name='sch原创 2012-06-14 19:01:49 · 1268 阅读 · 3 评论 -
SqlDataAdapter;DataSet;DataTable;DataTableCollection 关联
SqlDataAdapter;DataSet;DataTable;DataTableCollection SqlDataAdapter 一个桥梁用来从数据库获取数据 用来填充到 dataset 或 datatable中 dataset 就要当于一个数据库,也就是说可以包含多个表(datatable); datatable 就是一个表 也相当于 DataSet的原创 2012-06-17 15:03:58 · 2290 阅读 · 0 评论 -
多条件搜索,sql语句,决对经典的拼接写法
大家在做多条件的搜索时,最常用的办法是用ifelse 里面嵌套很多个。 当有五六个以上条件时,可以说写的直接崩溃了。 现在给大家介绍一个经典的拼接写法string sql = "select * from zhiyuan"; List listsql = new List();原创 2012-06-18 23:15:49 · 1542 阅读 · 0 评论 -
sql 不常用函数集合。mssql
--执行插入语句返回刚刚生成的自动编号insert into TblClass output inserted.tclassId values('xxx','..');--top 数字后加percent表示百分比,如果百分比最后计算出来的条数中有小数,则直接进位。select top 30 percent * from MyStudent order by fage desc--==原创 2012-06-14 19:16:03 · 1456 阅读 · 2 评论 -
2012.6.19.sql不常用函数总结,以及事务,增加,删除触发器
distinct 删除重复行declare @x 申明一个变量convert(varchar(20),tscore.tenglish) 类型转换 cast(xx as varchar(10)) 类型转换======================================================情况case when xxx then xx原创 2012-06-19 19:22:34 · 1889 阅读 · 1 评论 -
NPOI.dll 用法。单元格,样式,字体,颜色,行高,宽度。读写excel
我用的版本是1.25的。每个版本用法有一点不同using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows原创 2012-06-24 10:49:47 · 13963 阅读 · 6 评论 -
通过反射获取SqlConnection连接池中的连接字符串
string constr = "Data Source=.;Initial Catalog=xhc;Integrated Security=True"; //获取类型中的私有成员 PropertyInfo pInfo = typeof(SqlConnection).GetProperty("InnerConnection",原创 2012-06-25 18:12:57 · 994 阅读 · 0 评论 -
通过WebClient操作ftp
#region 下载! //WebClient wc = new WebClient(); //wc.Credentials = new NetworkCredential("yzk", "1234"); //wc.DownloadFile("ftp://192.168.1.100/顶.gif", @"c:\a.gif");原创 2012-06-25 18:15:39 · 2752 阅读 · 0 评论 -
教你怎么使用sql游标
--1.将每个老师的工资更新为原来的工资+奖金--定义两个变量,用来存储ttid与rewarddeclare @tid intdeclare @reward money--1。建立一个基于奖金表的游标declare cur_reward cursor fast_forward for select ttid,reward from TblTeacherSalary--2.打开游标原创 2012-06-23 09:29:10 · 679 阅读 · 0 评论 -
.net中MD5使用方法
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Security.Cryptography;using System.IO;namespace MD5练习{ public static class MD5String {原创 2012-06-23 10:37:40 · 1402 阅读 · 0 评论 -
FtpClient 类来操作FTP的上传和下载,带进度条
先给出FtpClient 类(还没有做完。明天继续)using System;using System.Collections.Generic;using System.Net;using System.IO;using System.Windows.Forms;namespace FTPXHC{ /// /// FTP客户端操作类 /// p原创 2012-06-25 22:46:25 · 4687 阅读 · 0 评论 -
汉字转拼音。简繁体互转。ChnCharInfo.dll,ChineseConverter.dll
汉字转拼音using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Micro原创 2012-06-25 23:24:44 · 3744 阅读 · 0 评论 -
2012.6.11 加载xml到treeView 上
XDocument doc = XDocument.Load(@"c:\test.xml"); XElement root = doc.Root; TreeNode tn= treeView1.Nodes.Add(root.Name.ToString()); getxml(tn, root);原创 2012-06-11 20:53:36 · 336 阅读 · 0 评论 -
2012.6.11 xml读。写
xml 读加载xml文件XDocument doc = XDocument.Load("xl.xml");获取xml的根节点XElement xe = doc.Root; 获取xe节点下的 items节点 XElement its = xe.Element("items"); 获取xe节点下的所有子节点List item = its.Elements().T原创 2012-06-11 20:51:47 · 426 阅读 · 0 评论 -
2012.6.4 ArrayList集合 List泛型 Hashtable键值对的集合 Dictionary
对于以上四种其实就分两种1 . List泛型2. Dictionary键值集合 Dictionary 存储模式相当于字典一样 。查找的速度相当之快当我要查找一个键对应的值时,他会根据键的内存地址来直接查找,而不是遍历所有数据;也推荐 我们使用这两种,相当于是前面的生级版。好用#region 练习:计算字符串中每种字符出现的次数(面试题)。 “Welcome to原创 2012-06-04 19:35:15 · 843 阅读 · 0 评论 -
2012.6.3ref 用法
ref 传参过去,并保留得到值:引用类型static void sy(string msg, string word, ref int n,ref int syn) { syn = msg.IndexOf(word,syn); if ( syn> -1) {原创 2012-06-04 19:25:45 · 441 阅读 · 0 评论 -
2012.6.3关于ReferenceEquls 和Equls
ReferenceEquls 是真正比较两个对像是否相等,他比较的是堆地址 而Equls 他实现比较的不是对像,比较的是值因为他被很多对像重载了原创 2012-06-04 19:28:37 · 282 阅读 · 0 评论 -
2012.6.4类,抽像类,接口
普通类,抽像类相同点 -》继承继承后,构造函数不继承,子类的构造函数要和父类一致。在子类构造函数后要跟base();继承的单根性,也是只能继承一个父类 不同点--》多态普通类:先在父类实现虚方法public virtual void w() { }然后在子类实现多态 public override void w()原创 2012-06-04 22:36:25 · 312 阅读 · 0 评论 -
2012.6.6装箱、拆箱
1.装箱、拆箱必须是: 值类型→引用类型 或 引用类型→值类型。//object,接口。值类型是可以实现接口。 //Person p=new Student();//这个叫隐式类型转换,不叫装箱。//Student stu=(Student)p;//这个叫显示类型转换,不叫拆箱。//int类型为什么能装箱到object类型,但不能装箱到string类型或Person类型,/原创 2012-06-06 11:24:26 · 583 阅读 · 0 评论 -
泛型,自定义泛型,foreach
Mylist my = new Mylist(); for (int i = 0; i < 100; i++) { my.Add(i.ToString()); } foreach (var item in my) {原创 2012-06-06 09:47:22 · 370 阅读 · 0 评论 -
2012.6.6泛型,自定义泛型,foreach 生级版
关于想使用foreach必须现实GetEnumerator()方法 static void Main(string[] args) { M m = new M(); for (int i = 0; i < 10; i++) { m.Add(i);原创 2012-06-06 09:50:23 · 2173 阅读 · 0 评论 -
2012.6.6文件操作
Path目录和文件操作的命名控件System.IOstring ChangeExtension(string path, string extension) (*)修改文件的后缀,“修改”支持字符串层面的,没有真的给文件改名string s = Path.ChangeExtension(@"C:\temp\F3.png", "jpg")string Combine(stri原创 2012-06-06 14:25:33 · 317 阅读 · 0 评论 -
2012.6.6文件操作,大文件传输
public Form1() { InitializeComponent(); label1.Text = ""; System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; } private原创 2012-06-06 14:30:53 · 304 阅读 · 0 评论 -
2012.6.6文件操作实例(树型)
文件操作(树形)TreeNode trn;trn = treeView1.Nodes.Add("打开查找");getfiles(ppath, trn);#region 递归 void getfiles(string path, TreeNode tn) { try {原创 2012-06-06 14:28:17 · 291 阅读 · 0 评论 -
2012.6.7文件序列化/反序列化
//序列化 //Person p=new Person(); //p.Name="夏华成"; //p.Age=29; //BinaryFormatter bf = new BinaryFormatter(); //using(FileStream fs=new FileStrea原创 2012-06-07 19:12:04 · 1014 阅读 · 0 评论 -
WeakReference 弱引用
string srr = "123";WeakReference wr = new WeakReference(srr); srr = null; object o = wr.Target; if (o != null) { Console.WriteLin原创 2012-06-06 21:07:24 · 371 阅读 · 0 评论 -
2012.6.7正则表达式 分组用法
Regex rx = new Regex(@"[A-Z0-9a-z\.\-_]+@([a-z0-9]+)\.[a-z0-9A-z]"); string html = File.ReadAllText("1.htm"); //提取Email, //通过()提取组。 //fd(s(a(f原创 2012-06-07 20:11:43 · 1255 阅读 · 0 评论 -
2012.6.10关于委托和对象的多态?
对象多态先把可能的几种方法写在类里,在程序调用的时候 实例父类的子类类型,进行调用 委托我也觉得是多态的体现委托,是一个方法变量。这方法一定是变量的。这也相当于是一个多态的体现吧 委托只有多态特征而多态只是对象的其中一个特性心存疑惑,但又不知道疑惑在哪里原创 2012-06-10 11:24:48 · 289 阅读 · 0 评论 -
2012.6.10 事件
事件也是 委托事件和委托用法一样 只是赋值的时候只能用 += class Program { static ShaoShui ss = new ShaoShui(); static void Main(string[] args) { // ss.evshaoshui = ss_evshaoshui;原创 2012-06-10 20:26:05 · 347 阅读 · 0 评论 -
2012.6.10 反射,插件制做
对外接口:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;namespace 对外接口{ public interface Ijiekou { string Name原创 2012-06-10 21:47:28 · 285 阅读 · 0 评论 -
2012.6.8委托的理解和其本用法
什么是委托委托就是一种数据类型,是引用类型,其实就是一个类 既然是一种数据类型,就可以被申明,赋值,和作为参数传递 那他是怎样一种数据类型呢他就是用来存储方法的数据类型当然我们需要传递一个方法时,可用到委托,非常方便 例子1 public delegate void Getdelegate();//申明委托 public class Class1原创 2012-06-10 10:11:28 · 276 阅读 · 0 评论 -
treeView的一些常用用法
递归加载 这里有点不好理解。先写个函数得到父ID下的子节点 /// /// 根据pid获取所有的子类别 /// /// /// public List GetScriptsByParentId(int pid) { List list = ne原创 2012-06-27 13:52:18 · 657 阅读 · 0 评论