
c#
h82258652
这个作者很懒,什么都没留下…
展开
-
快速排序
public static void QSort(int[] array, int low, int high){ int left = low; int right = high; int pivotkey = array[left]; while (left < right) { while (left = pivotkey)原创 2012-12-24 11:34:10 · 357 阅读 · 0 评论 -
c#获取字符串md5
public static string GetMD5(string sDataIn) { System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); b转载 2013-07-20 23:36:15 · 7035 阅读 · 0 评论 -
C#运算符重载例子
一个复数类的加减法 class Complex { public double Real { get; set; } public double Imaginary { get; set; }原创 2013-07-20 22:49:05 · 1044 阅读 · 0 评论 -
Linq成绩分组
int[] scores = { 15, 37, 50, 77, 91, 23, 48, 60, 83, 100 }; var scoreGroup = from score in scores orderby score descending// 先由高到低排序原创 2013-08-23 17:50:16 · 836 阅读 · 0 评论 -
新线程启动窗口
new System.Threading.Thread(() => { Application.Run(new Form()); }).Start();转载 2013-08-15 01:19:50 · 1054 阅读 · 0 评论 -
wpf值转换器用法
前台xaml<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"原创 2013-09-06 23:14:25 · 1046 阅读 · 0 评论 -
在 C# 中实现 Singleton
版本: 1.0.1*本页内容 上下文 上下文 实现策略 实现策略 结果上下文 结果上下文 致谢 致谢 上下文您要在 C# 中构建应用程序。您需要只有一个实例的类,并且需要提供一个用于访问实例的全局访问点。您希望确保您的解决方案高效,并且能够利用 Microsoft? .NET 公共语言运行库功能。您可能还希望确保解决方案是线程安全的。 返回页首 实现转载 2013-10-15 17:01:16 · 481 阅读 · 0 评论 -
C# Random增强类 1.0
c#下random类功能增强,实现多种数据类型的随机原创 2013-12-01 14:00:13 · 2594 阅读 · 0 评论 -
Asp.Net MVC 2使用Ext.Net 1.3
首先,用的是VS2010。如果没有NuGet的话,工具-〉扩展管理器-〉联机库-〉搜索NuGet,安装,完成后重启VS。打开Asp.Net MVC 2项目,工具-〉库程序包管理器-〉程序包管理器控制台。输入命令Install-Package Ext.NET -Version 1.3.0。等待安装完成后,在全局路由文件Global.asax中添加路由routes.IgnoreRoute(原创 2014-01-10 13:06:09 · 943 阅读 · 0 评论 -
c#中自定义类转换
隐式转换使用implicit关键字显示强制转换使用explicit关键字例子:class C1{ public static implicit operator C1(C2 c2) { return new C1(); } // 返回类型为C1,即赋值号左边的类型,C2为赋值号右边的类型 // 即C1 c1=c2;}// 自定义显示强制转换class C3{原创 2014-03-05 23:05:47 · 995 阅读 · 0 评论 -
wpf后台代码数据绑定
using System;using System.Collections.Generic;using System.ComponentModel;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;us原创 2014-03-05 23:09:13 · 16691 阅读 · 0 评论 -
c#中char.IsDigit和char.IsNumeric的区别
char c = '\u2160';// 罗马字母一:Ⅰ Console.WriteLine(c);// output:Ⅰ Console.WriteLine(char.IsNumber(c));// output:True Console.WriteLine(char.IsDigit(c));// output False即转载 2014-03-12 22:24:39 · 5877 阅读 · 0 评论 -
C#控件缩写
C#里边的控件缩写大全(比较规范)标准控件1 btnButton 2 chkCheckBox 3 ckl CheckedListBox4 cmb ComboBox 5 dtpDateTimePicker 6 lblLabel 7 llb LinkLabel 8 lstListBox转载 2013-07-20 22:56:51 · 1101 阅读 · 0 评论 -
WPF数据绑定步骤
为什么要定义一个类型,为了方便尽量不操作控件。MVVM、MVC。1、定义类,定义属性。2、new一个类的实例,给要绑定的控件设定DataContexttxtName.DataContext =p1;3、XAML中要进行数据绑定的属性Text="{Binding Name}",几乎所有属性都能进行这样的数据绑定。转载 2013-07-20 14:16:53 · 789 阅读 · 0 评论 -
mpq操作库
using System;using System.Collections.Generic;using System.IO;using System.Runtime.InteropServices;using System.Text;using System.Windows.Forms;using System.Diagnostics;using System.Reflection;原创 2013-01-23 12:15:15 · 2062 阅读 · 1 评论 -
归并排序
/// /// 归并排序/// /// 已排序的第一个数组/// 已排序的第二个数组/// 合并后的数组public static int[] MergeSort(int[] a, int[] b){ int[] result = new int[a.Length + b.Length];// 合并后的数组 int aIndex = 0, bIndex = 0;//原创 2012-12-26 12:06:25 · 392 阅读 · 0 评论 -
选择排序
/// /// 选择排序/// /// 需要排序的数组public static void SelectSort(int[] array){ int min;// 当前剩余数组的最小数的下标 for (int i = 0; i < array.Length; i++) { min = i; #region 查找数组中剩余的最小值的下原创 2012-12-26 21:52:20 · 373 阅读 · 0 评论 -
判断回文串
/// /// 判断是否为回文串/// /// 需要判断的字符串/// True是回文串,False不是回文串public static bool IsPalindrome(string str){ string temp = new string(str.Reverse().ToArray()); return temp == str;}原创 2012-12-26 23:52:32 · 715 阅读 · 0 评论 -
希尔排序
/// /// 希尔排序/// /// 需要排序的数组public static void ShellSort(int[] array){ int i, j, temp, length = array.Length, gap = length >> 2; for (; gap > 0; gap >>= 2) { for (i = gap; i <原创 2012-12-26 23:31:59 · 374 阅读 · 0 评论 -
求最大公约数
/// /// 使用Stein算法求最大公约数 /// public static int Gcd(int a, int b) { int k = 0;// 记录两原数为2的多少倍。原理:Gcd(ka,kb)==k*Gcd(a,b)。 for (; ; ) {原创 2012-12-19 23:53:10 · 436 阅读 · 0 评论 -
判断一个数是否为质数
/// /// 判断一个大于等于2的整数是否为质数/// /// True是质数,False不是质数public static bool IsPrime(int n){ if ((n & 1) == 0)// 等价于n%2==0 { return false; } int sqrn = (int)Math.Sqrt(n);// 求n的开方,原创 2012-12-20 10:03:39 · 788 阅读 · 0 评论 -
双向冒泡排序
/// /// 双向冒泡排序/// /// 需要排序的数组public static void TwoWayBubbleSort(int[] array){ int maxindex = array.Length - 1, left = 0, right = maxindex, i;// maxindex为数组最大下标,left为左游标,right为右游标 while (原创 2012-12-20 11:41:25 · 428 阅读 · 0 评论 -
求斐波那契数列第n项
/// /// 公式法求斐波那契数列/// public static int Fibonacci(int n){ double sqr5 = Math.Sqrt(5) * 0.5; return (int)((Math.Pow(0.5 + sqr5, n) - Math.Pow(0.5 - sqr5, n)) / sqr5 * 0.5);}/// /// 循环法求斐波原创 2012-12-12 15:05:29 · 771 阅读 · 0 评论 -
二分查找
/// /// 二分查找/// /// 需要查找的数组/// 需要查找的元素/// 若查找成功,则返回该元素在数组的下标,查找不到返回-1public static int BinarySearch(int[] array, int key){ int low = 0, high = array.Length - 1, mid; while (low <= high)原创 2012-12-20 11:12:19 · 394 阅读 · 0 评论 -
[c#]动态链接库获取自身目录
/// /// 获取这个动态链接库的位置/// /// private static string GetPath(){ string str = Assembly.GetExecutingAssembly().CodeBase; int start = 8;// 去除file:/// int end=str.LastIndexOf('/');// 去除文件名xx原创 2013-01-17 23:18:47 · 4283 阅读 · 0 评论 -
[c#]获取数据库中所有表的表名
public static IEnumerable GetDataBaseTableNames(DbConnection connection) { if (connection.State != ConnectionState.Open) { connection.Open();原创 2014-04-10 14:45:52 · 1207 阅读 · 0 评论