
c#
我扶奶奶过哈登
orz
展开
-
C#判断字符串是否是数字字符串
第一种方法 使用Try Catch(不推荐)private bool IsNumberic(string oText){ try { int var1=Convert.ToInt32 (oText); return true; } catch { return false; }}第二种方法 正则表原创 2016-08-16 17:12:21 · 2288 阅读 · 1 评论 -
c#:wpf入门
创建工程及工程结构教程Domo MainWindow.xaml<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winf原创 2016-09-21 13:09:23 · 1216 阅读 · 0 评论 -
c#:?的使用
今天看到一段代码public ActionResult New(Guid? id, FormCollection collection)参数里面怎么有个问号,还不报错,查一下才知道?的几种用法引用类型可以为null,值类型不能为null,但是如果想让值类型为null的话可以加上? 比如int? a = null;public void Test(int? b)三元运算符空合并运算符(右结合原创 2016-10-12 11:11:38 · 376 阅读 · 0 评论 -
c#:SMTP发送带图片邮件
使用SMTP发送邮件 发送的邮件为本地html文件,html中的图片为本地图片主体函数,根据传入的bool参数发送不同的模板internal class FeedbackMail{ public MailMessage mailMessage = new MailMessage(); public SmtpClient smtpClient; public int sen原创 2016-12-02 14:43:30 · 4719 阅读 · 1 评论 -
博大精深的VS的快捷键
熟练掌握快捷键是非常有用的,谁用谁知道Shift+Alt+Enter: 切换全屏编辑Ctrl+B,T / Ctrl+K,K: 切换书签开关 Ctrl+B,N / Ctrl+K,N: 移动到下一书签 Ctrl+B,P: 移动到上一书签 Ctrl+B,C: 清除全部标签Ctrl+I: 渐进式搜索 Ctrl+Shift+I: 反向渐进式搜索 Ctrl+F: 查找 Ctrl+Shift+F: 在转载 2016-08-25 16:55:52 · 315 阅读 · 0 评论 -
c#:操作resx资源文件
直接把resx当做xml文件进行操作即可。下面是我其他两篇关于XML操作的博客。虽然只有代码,但还是可以参考一下XML的操作。 c# 根据XML递归还原路径 c#用xml存电脑指定路径的目录原创 2016-11-24 11:41:08 · 924 阅读 · 0 评论 -
c#:用xml递归存电脑指定路径的目录
public static void StoreAllFilesToXml(string directoryPath, string destinationXmlFilePath, XmlNode parentNode, XmlDocument xmlDoc) { bool isFirst = false; if (parentNode原创 2016-08-17 18:00:06 · 911 阅读 · 0 评论 -
c#:使用百度翻译API
本来不想用百度的,但是bing的没整明白怎么用…..首先先在百度翻译开放平台上注册一下,然后得到两个关键值:App Id 和 秘钥,有了这俩就可以直接写程序了。写程序的时候参考一下开发手册因为最后的返回结果是这样的{"from":"en","to":"zh","trans_result":[{"src":"hello","dst":"\u4f60\u597d"}]}先定义一个Translation.原创 2016-11-25 15:18:47 · 3055 阅读 · 0 评论 -
c#:通过MD5得到文件和String的校验值
public static string GetMD5HashFromFile(string fileName){ try { FileStream file = new FileStream(fileName, System.IO.FileMode.Open, FileAccess.Read); MD5 md5 = new MD原创 2016-08-18 17:09:40 · 738 阅读 · 1 评论 -
c#:自定义Attribute
自定义Attribute类:VersionAttribute[AttributeUsage(AttributeTargets.Class)]public class VersionAttribute : Attribute{ public string Name { get; set; } public string Date { get; set; } public s原创 2016-09-20 15:14:44 · 1307 阅读 · 0 评论 -
c# SqlServer DbHelper类
DbHelper.csinternal class DbHelper{ public static String GetConnectionString(ConnectionStringPattern pattern) { String connectionString = String.Empty; switch (pattern)原创 2016-08-25 16:45:43 · 1910 阅读 · 0 评论 -
c#:SharpSvn关于SVN操作
下载SharpSvn 1.8 在工程里引用其中的 SharpSvn.dllUpdatepublic static void SvnDownload(){ using (SvnClient client = new SvnClient()) { //client.Authentication.Clear(); client.Authenticatio原创 2016-09-15 11:05:55 · 6051 阅读 · 0 评论 -
c# int数组 每个int的各个位排序 和数组排序
如题 给一个整数数组,对数组中的每个整数中的所有数字按照升序排列(如101排序后为011)请写一个方法,输出排序后的数组中的最大数。 例如有一个数组: 101、132、375,排序后011、123、357,所以其中最大的数是357。解using System;using System.Collections.Generic;using System.Linq;using System.Te原创 2016-08-16 17:39:13 · 3960 阅读 · 0 评论 -
c# 文件操作的一些函数
遍历文件夹public void GetAllFiles(string directoryPath){ var rootDirectory = new DirectoryInfo(directoryPath); foreach (var file in rootDirectory.GetFiles()) { Console.WriteLine("F原创 2016-08-17 14:34:59 · 480 阅读 · 0 评论 -
c# 根据XML递归还原路径
可以根据XML恢复目录至指定地点 创建的文件为空 xml如下<?xml version="1.0" encoding="utf-8"?><directory_root directory_fullname="C:\Users\nhuang\Documents\学习资料"> <folder name="图书资料" directory_modify_time="2016/8/17 8:13:原创 2016-08-18 17:03:55 · 791 阅读 · 0 评论 -
c# log类
将log日志输出到指定地点public static void MyLog(string logPath, string logInformation){ StreamWriter log = new StreamWriter(logPath, true); log.WriteLine(logInformation); log.Close();}原创 2016-08-18 17:05:32 · 928 阅读 · 1 评论 -
c#:简单WCF demo
在网上看的教程之前都是 四个工程 Contract+Serice+Host+Client 但是vs2015里面支持新建WCF工程 先新建一个空工程 在里面新建一个WCF Service Library 里面会创建contract和service 分别叫IService1和Service1 里面默认定义和实现了一个 string GetData(int value); 的函数 一会原创 2016-09-12 12:13:37 · 673 阅读 · 0 评论 -
c#:自定义泛型栈实现 IEnumerable IEnumerator
只有继承 IEnumerable IEnumerator 的类才能使用foreach。 点进去看可以看到IEnumerable的接口定义的是public interface IEnumerable<out T> : IEnumerable继承了IEnumerable IEnumerable只有一个方法,返回可循环访问集合的枚举数 IEnumerator GetEnumerator() ;d原创 2016-09-13 12:51:34 · 1028 阅读 · 0 评论 -
c#:反射访问私有变量
反射是反射dll程序集中的信息 用反射可以做几件事,下面演示如何访问private比如这有一个Class Library 叫TicketLibrary 里面有一个Class叫TicketInfo TicketInfo.cs 里面有一个叫ticketList的private static Listnamespace ReflectTest{ public class TicketI原创 2016-09-14 10:12:02 · 3708 阅读 · 0 评论 -
c# 连接sqlserver
先创建一个连接函数private static string GetConnectionString(ConnectionStringPattern pattern){ string connectionString = string.Empty; switch (pattern) { case ConnectionStringPattern.ByString原创 2016-08-24 13:34:23 · 467 阅读 · 0 评论 -
c#:使用bing翻译API
百度翻译太弱了,有很多小语种不提供翻译,所以还是用强大的bing翻译吧。 bing支持的语言缩写百度翻译 bing翻译官方demo Github Github上也写了每个文件是干什么的 先注册一个账号 注册之后得到id 和 秘钥,然后直接放到demo里。注github中有很多文件,每个cs文件就是一种例子,按需打开。原创 2016-11-28 15:16:12 · 2940 阅读 · 0 评论