![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C#
文章平均质量分 63
ws_hgo
个人爱好:篮球,看书,音乐,电影.
夫英雄者,胸怀大志,腹有良谋,有包藏宇宙之机,吞吐天地之志者也.
展开
-
C# 中的this
this引用的第二种用法是把当前对象作为参数传给另一个方法 class Class1 { static void Main() { MyClass vMyClass = new MyClass(); UClass vUClass = new UClass(); Console.WriteL原创 2008-12-25 16:05:00 · 1157 阅读 · 0 评论 -
将数组中指定数量的元素移动数组后面
static void Main() { int[] array = { 1, 2, 3, 4, 5, 6, 7 }; MoveNumberArrayToEnd(array, 3); } static void MoveNumberArrayToEnd(IList arrayList, int num)原创 2011-11-04 11:10:15 · 1941 阅读 · 0 评论 -
求算一任意长度字符串中不同的字符以及它的个数
(1) static void Main(string[] args) { string a = "abcdefgabc"; int i = a.Length; while (i > 0) { Console.WriteLine(a[0].原创 2009-02-02 10:55:00 · 2228 阅读 · 3 评论 -
基本的文件 I/O 用法:1.复制目录及其文件 2.文件创建,写入,读取,删除,复制
1.Directory类:公开用于创建,移动和枚举目录和子目录的实例方法下面的Demo 演示了如何复制目录及其文件 static void Main() { DirectoryInfo source = new DirectoryInfo(@"D:\Practise\IO\Source"); DirectoryInfo原创 2011-12-02 15:46:26 · 1241 阅读 · 0 评论 -
使用Deflate算法对文件进行压缩和解压缩
static void Main() { string path = @"D:\Practise\IO\Compress"; string deCompressPath = @"D:\Practise\IO\DeCompress"; DirectoryInfo dir = new DirectoryInfo原创 2011-12-08 13:50:08 · 7552 阅读 · 0 评论 -
有一组数字,从1到n,从中减少了3个数,顺序也被打乱,放在一个n-3的数组里,请找出丢失的数字,最好能有程序,最好算法比较快
static void Main() { GetRemoveNumbers(1000, 3).ForEach(n => Console.WriteLine("{0}", n)); } public static List GetRemoveNumbers(int count,int removeCount) {原创 2012-01-04 16:58:00 · 4755 阅读 · 0 评论 -
C# 多态性
MSDN 上面的定义:通过继承,一个类可以有多种类型:可以用作它自己的类型,任何基类型,或者在实现接口时用作任何接口的类型。从两个方面来说明多态1.在运行时,方法参数和集合或者是数组等位置,派生类的对象都可以作为基类的对象处理,发生此情况时,该对象的声明类型不再与运行时类型相同。2.基类定义实现虚方法,派生类重写这些方法,在运行时,CLR会查找运行时类型,并且调用派生类重写的方法. clas原创 2012-01-16 17:10:02 · 2650 阅读 · 0 评论 -
将一个整型转换为整型数组例如Int num = 5546798;转为int [] {5,5,4,6,7,9,8}(不能转换为字符串)
static void Main() { int number = 4563581; ArrayList array = new ArrayList(); while (number > 0) { array.Add(number % 10);原创 2012-02-13 14:56:01 · 3607 阅读 · 0 评论 -
使用反射调用类型成员 方法,字段,属性
class Program { static void Main(string[] args) { Type t = typeof(Test); object result; Test tc =new Test(); Console.WriteLine("Invo原创 2012-04-11 10:19:56 · 3061 阅读 · 0 评论 -
使用委托,匿名方法对集合进行万能排序
下面Demo中我使用了2种排序方式1.让Employee继承IComparable 接口,实现CompareTo方法排序2.定义一个方法使用Comparison委托,排序的操作交给匿名方法 看完下面的代码,你知道使用Comparison委托的好处吗? class Employee:IComparable { public string Name { get; set;原创 2012-04-30 18:07:10 · 3346 阅读 · 0 评论 -
使用迭代器 遍历文件的信息
1.迭代文件的行 public static IEnumerable ReadLines(string fileName) { using (TextReader reader = File.OpenText(fileName)) { string line;原创 2012-05-01 17:47:46 · 3337 阅读 · 0 评论 -
C# 异或运算符
class XorArithmetic { static void Main() { XorArithmetic.UseNumericType(); int a = 10; int b = 6; Console.WriteLine("befo原创 2012-08-01 14:44:33 · 11845 阅读 · 0 评论 -
使用XMLSerialize 序列化和反序列化
概念:XML序列化是将公共字段和属性转化为序列格式(这里指XML),以便存储或传输的过程。反序列化则是从XML中重新创建原始状态的对象. class SerializeDemo { static void Main() { EmployeeCollection employeeCollection = new Empl原创 2012-08-06 10:52:32 · 7040 阅读 · 0 评论 -
线程同步
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Threading;namespace ConsoleApplication1{ class MutilThread { pu原创 2012-07-23 22:28:02 · 2918 阅读 · 0 评论 -
输出本月的月历
格式要气:SU MO TU WE TH FR SA 01 02 03 0405 06 07 08 09 10 1112 13 14 15 16 17 1819 20 21 22 23 24 2526 27 28 29 30代码: class Interview1 { static void Main() {原创 2011-10-29 16:28:35 · 1161 阅读 · 0 评论 -
Func 委托
Func 委托原创 2011-05-09 13:45:00 · 1225 阅读 · 2 评论 -
Ref,Out的理解及其使用
class Program { //使用out后必须对变量赋值 public void TestOut(out int x, out int y) { x = 1; y = 2; } //此时传进来的值分别为x1:10,y1:11,输出之后的x1原创 2009-04-11 11:36:00 · 1286 阅读 · 0 评论 -
从1到20间随机生成6个互不相同的整数。
protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { CreateNum(); } } //在从1到20间随机生成6个互不相同的整数。 public void Create原创 2009-05-09 22:42:00 · 2114 阅读 · 0 评论 -
用委托处理排序
using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ class 冒泡排序 { //首先要了解冒泡排序,其实很简单就是索引前面的跟后面的比较,如果比后面的大2个值的位置就进行调换 sta原创 2009-07-25 21:18:00 · 950 阅读 · 1 评论 -
Base关键字的使用
using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ class 继承1 { //virtual虚函数,这样写便于子类重写 public virtual double Area(doub原创 2009-07-26 17:22:00 · 903 阅读 · 0 评论 -
委托实例和多播委托
using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ class 简单的委托实例 { public static double Area(double Val) {原创 2009-07-25 21:24:00 · 1099 阅读 · 2 评论 -
接口实例
namespace ConsoleApplication1{ using System; using System.Collections.Generic; using System.Text; public class BankMethod : IBankAccount { decimal balance;原创 2009-07-30 19:26:00 · 824 阅读 · 0 评论 -
IComparable,IComparer排序实例
using System;using System.Collections.Generic;using System.Text;using System.Collections;namespace hgoApp{ class Comparer { static void Main() { E原创 2009-08-02 18:53:00 · 1160 阅读 · 1 评论 -
使用List类实例
using System;using System.Collections.Generic;using System.Text;namespace hgoApp{ public class Racer { private string _Name; public string Name {原创 2009-08-02 19:22:00 · 859 阅读 · 0 评论 -
反射实例
这个文字部分来自博客园什么是反射?Reflection,中文翻译为反射。这是.Net中获取运行时类型信息的方式,.Net的应用程序由几个部分:‘程序集(Assembly)’、‘模块(Module)’、‘类型(class)’组成,而反射提供一种编程的方式,让程序员可以在程序运行期获得这几个组成部分的相关信息,例如: Assembly类可以获得正在运行的装配件信息,也可以动态的加载装配件,以及原创 2009-08-04 20:05:00 · 893 阅读 · 0 评论 -
C# 中is,As运算符号
using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{ class IsOrAsClass { class Animal { public void Eat()原创 2009-12-06 14:39:00 · 1024 阅读 · 0 评论 -
反射生成数组
看了下建哥的用反射生成的数组(http://blog.csdn.net/ojlovecd/archive/2008/11/11/3277766.aspx)感觉不错,学习下,(1)第一个例子是public MethodInfo GetMethod(string name, Type[] types) 代码如下using System;using System.Collecti原创 2009-12-26 16:20:00 · 1055 阅读 · 4 评论 -
C#组合函数
C#组合函数原创 2010-07-19 11:30:00 · 1350 阅读 · 1 评论 -
C# 继承,虚方法,new
C# 继承,虚方法,new原创 2010-11-17 10:54:00 · 2998 阅读 · 6 评论 -
使用多线程异步创建一组文件
使用多线程异步创建一组文件原创 2014-07-10 14:16:29 · 3486 阅读 · 0 评论