
C#
StevenShi_DaShi
修品行,守正道!
展开
-
简单的C#Windows 窗体编程,计算圆的周长、面积与体积。
简单的C#Windows 窗体编程,计算圆的周长、面积与体积。转载 2016-08-05 09:32:09 · 18155 阅读 · 0 评论 -
C#判断是不是回文
static void Main(string[] args) { Console.WriteLine(“请输入文字:”); string a = Console.ReadLine(); int flag = 0; int i = 0; int j =原创 2017-03-01 09:49:18 · 849 阅读 · 0 评论 -
C# 静态方法与动态方法
类的实例化可以调用非静态方法 但是静态的方法必须由类直接调用 class Te{ public static void S() {} } class program(){ public static void main(string args[])Te t=new Te() t.s//错误 Te.s//正确}原创 2017-03-02 11:16:25 · 1639 阅读 · 0 评论 -
C# 参数数组
1、形参含有一个数组,数组必须放在最后。 2、参数数组是一个一维数组 3、不能将params 与ref 与out 修饰符结合起来 4、与参数数组对应的实参可以是同一参数名,也可以是任意多个与该数组元素一致的类型的变量。 using System; using System.Collections.Generic; using System.Linq; using System.Text原创 2017-03-02 16:08:57 · 1156 阅读 · 0 评论 -
C# 方法的重载
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication12 { class Program { static void M原创 2017-03-03 10:24:46 · 691 阅读 · 0 评论 -
C#窗体程序的退出
Application.Exit();原创 2017-02-26 10:51:40 · 548 阅读 · 0 评论 -
C#简单的函数调用
class Program { static void Main(string[] args) { L(); Console.ReadKey(); } public static void L() { int i = 20;原创 2017-02-26 10:56:18 · 1037 阅读 · 0 评论 -
C# 三角形求斜边
public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { double a = Convert.ToDouble(textBox1.Text); doub原创 2017-02-26 11:14:04 · 3833 阅读 · 1 评论 -
C# switch 语句的简单应用
public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int a =Convert.ToInt16(textBox1.Text); int b = 0原创 2017-02-26 11:38:22 · 783 阅读 · 0 评论 -
C# continue 语句的使用
continue一般配合if使用 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication4 { class Program {原创 2017-02-26 11:53:41 · 1203 阅读 · 0 评论 -
C#中的foreach语句
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication5 { class Program { static void Ma原创 2017-02-26 15:55:20 · 701 阅读 · 0 评论 -
C# 合并两个窗体
Form1 f = new Form1(); f.Show(); 1是一个已有的想要引用的窗体,在你的代码中通过这种方式引用。原创 2017-02-26 17:22:39 · 2486 阅读 · 0 评论 -
C# 的方法的嵌套
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication6 { class Program { static double fa原创 2017-02-27 11:36:44 · 3542 阅读 · 0 评论 -
C#递归调用
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication7 { class Program { static void Main(str原创 2017-02-27 11:56:31 · 892 阅读 · 0 评论 -
输出100以内质数
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication8 { class Program { static void Ma原创 2017-02-27 16:33:09 · 1043 阅读 · 0 评论 -
C# object 类型
是个对象类型 Object 数据类型 保存引用对象的 32 位(4 字节)地址。可以为 Object 的变量分配任何引用类型(字符串、数组、类或接口)。Object 变量还可以引用任何值类型(数值、Boolean、Char、Date、结构或枚举)的数据。 Object 数据类型可以指向任意数据类型的数据,包括您的应用程序识别的任意对象实例。当您在编译时不知道变量可能指向哪种数据类型时,请使用 Ob转载 2017-03-01 09:30:33 · 6704 阅读 · 0 评论 -
C# string.Format 实用方式
String.Format是将指定的 String类型的数据中的每个格式项替换为相应对象的值的文本等效项。 class Program { static void Main(string[] args) { int n = 5; string s; s = string.F原创 2017-03-01 09:17:28 · 338 阅读 · 0 评论 -
C#辗转相除法求最大公约数与最小公倍数
class Program { static void Main(string[] args) { int num1, num2, mm; Console.WriteLine(“请输入第一个数:”); num1 = Convert.ToInt32(Console.ReadLin原创 2017-02-28 10:25:15 · 7967 阅读 · 0 评论 -
如何使用C#Windows窗体完成文件浏览功能:
如何使用C#Windows窗体完成文件浏览功能: 1、简单界面如下: 2、点击上传按钮浏览本地文件: 3、显示上传文件名: 步骤: 1、在主界面上加入openFileDialog窗体插件。 2、进入代码部分的对应的点击事件: private void button1_Click(object sender, EventArgs e) {原创 2016-08-05 11:35:49 · 11436 阅读 · 2 评论 -
数组实现随机数并判断最大值以及位置
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace shuzujichu{ class Program { static void Main(string[] args)原创 2016-08-06 09:31:43 · 827 阅读 · 0 评论 -
C#选择排序的实现
排序经常用到的两种基本排序方法:选择排序和冒泡排序 选择排序:将数组中第一个元素分别于其他元素比较,实现从大到小或者是从小到大的排序实现。实现原理图: static void Main(string[] args) { const int n = 10; int [] a = new int [n]; in原创 2016-08-06 15:50:15 · 340 阅读 · 0 评论 -
foreach 语句的使用
foreach 语句用于对数组、集合等数据结构中的每一个元素进行循环操作时十分方便。 格式: foreach(数据类型符 变量名 in 数组或者是集合) 例子:求二维数组中的最小值using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threadi原创 2016-08-30 09:31:22 · 716 阅读 · 0 评论 -
折半查找(二分查找)实现
折半查找是一种在有序数列中快速查找数据的一种方法。 实现基本原理:每次查找前提前确定待查数组的下标范围,然后用m(待查数据)与中间元素比较,如果m大于中间元素则向中间元素与的中间数据上面查;反之则向下面查找。 折半原理图: static void Main(string[] args) { int[] a = { 1, 2, 3, 4, 6, 8, 9原创 2016-08-30 15:45:34 · 409 阅读 · 0 评论 -
C# 冒泡排序实现
随机产生10 个整数 从小到大排序: 原理:外层循环代表比较轮数,内层循环实现相邻的数值两两比较。 const int n = 10; int[] a =new int [n]; int t; Random random = new Random(); for (int i = 0; i < n;i+原创 2016-08-10 09:10:23 · 320 阅读 · 0 评论 -
求二维数组的鞍点
鞍点是指数组中本行最大,本列最小的数值。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace shuzuandian{ class Program { static voi原创 2016-09-01 11:19:26 · 834 阅读 · 0 评论 -
C#简单的方法调用
实现一个简单的求数字平方的发放调用class Program { public static double Sqr (double k) { return (k * k); } static void Main(string[] args) { double y;原创 2016-09-01 15:18:17 · 344 阅读 · 0 评论 -
C#异常处理try catch
原文地址:点击打开链接本文翻译自CodeProject上的一篇文章,原文地址。目录介绍做最坏的打算 提前检查 不要信任外部数据 可信任的设备:摄像头、鼠标以及键盘 “写操作”同样可能失效安全编程 不要抛出“new Exception()” 不要将重要的异常信息存储在Message属性中 每个线程要包含一个try/catch块 捕获转载 2016-09-03 09:02:25 · 2652 阅读 · 0 评论 -
C#参数的传递:值传递、引用传递、输出参数
许多方法是需要传递参数的:传递的参数分为:值传递、引用传递、输出参数、参数数组。 1、值传递: 把实参复制给形参,从此两者无关系。 2、引用传递: 实参复制给形参、形参也可以通过函数改变原始的实参。 3、输出参数: 允许在函数中修改实参的值、也允许在函数中将变量初始化。 实例:namespace 参数传递{ class Program { static原创 2016-09-03 09:36:59 · 879 阅读 · 0 评论 -
C# datable clone与copy的区别
DataTable.Clone 方法:克隆 DataTable 的结构,包括所有 DataTable 架构和约束。DataTable.Copy 方法:复制该 DataTable 的结构和数据。转载 2016-09-04 11:17:38 · 487 阅读 · 0 评论 -
C#的递归调用
若干个人排成一队领取苹果,第一个人领取一个,后面的每一个人领取的是前面苹果数的两倍两倍再加上3个,请问第n个人的领了几个苹果。static int apple (int n) { int k; if (n == 1) k = 1; else k = 2 * apple(n - 1) + 3; return原创 2016-09-07 10:10:02 · 924 阅读 · 0 评论 -
C#实现矩阵的转置
static void ArrayCon( ref int [ ,]a,int n) { int i, j, t; for(i=0;i<n;i++) for (j = 0; j < i; j++) { t = a[i, j];原创 2016-09-07 10:45:26 · 6128 阅读 · 0 评论 -
C# 数组越界的一场处理
数组越界的异常处理 static void Main(string[] args) { double[] a = { 1,23,56,32,56,8,89,32,56,77}; double pjcj = 0; int i; try { for(i=0;i原创 2016-09-08 10:59:55 · 3399 阅读 · 0 评论 -
C#处理excel引用Microsoft.Office.Interop.Excel
如果需要使用C#处理excel,需要引用Microsoft.Office.Interop.Excel;如何找到这个dll文件啊。 (1)windows 全盘搜索 Microsoft.Office.Interop.Excel; (2)将这个DLL文件加载至你的项目中原创 2016-10-15 23:08:58 · 12473 阅读 · 0 评论 -
C# 的异常处理
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace B_8_1 { class Program { static void Main(string[] ar原创 2017-03-16 10:53:54 · 395 阅读 · 0 评论