![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C#
潇洒哥Kahn
潇洒哥,一个被IT行业耽误多年的优秀保安。
展开
-
C#正则表达式之从字符串文件路径中提取文件名和后缀名
#region 09_从字符串文件路径中提取文件名和后缀名 //string path = @"c:\windows\system32\drivers\etc\host.txt"; Console.WriteLine("请输入完整文件路径:"); string path = Console.ReadLine(); ...原创 2019-04-02 16:42:52 · 3529 阅读 · 0 评论 -
c#正则表达式之从提取内容中再次提取(提取组)
#region 08_正则表达式之从提取内容中再次提取(提取组) //1.读取文件内容到字符串 string html = File.ReadAllText(@"D:\c\字符串提取\字符串提取\量房意向书\index.html"); //2.创建正则表达式抓取email地址 MatchColl...原创 2019-04-02 16:42:45 · 2849 阅读 · 0 评论 -
C#正则表达式提取指定词语出现的次数以及索引位置
#region 07_正则表达式提取指定词语出现的次数以及索引位置 string msg = "离婚只是表象,09年宋为了钱把马让给宝强搞了六年,中途13年一次车祸宝强在车上没睡躲过去了,15年一次车祸把亲戚撞死了,宝强命大,这两次都是只有熟人知道宝强行程才能策划的!针对他来的,宝强死了对谁好?亲子鉴定不用做了,直接继承遗产了,多好!算是当代武大郎了!我劝水军收声吧,再下...转载 2018-12-03 11:15:22 · 2442 阅读 · 3 评论 -
C#正则表达式之从本地指定文档中提取EMAIL
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Text.RegularExpressions;using System.Runtime.Serialization.Formatters...原创 2018-12-03 11:15:08 · 638 阅读 · 0 评论 -
c#正则表达式提取字符
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Text.RegularExpressions;using System.Runtime.Serialization.Formatters...原创 2019-04-02 16:42:33 · 7500 阅读 · 0 评论 -
C#正则表达式-元字符介绍
正则表达式(一) -- 元字符正则表达式括号的作用1、限制多选项的范围 (Fri|1)st 这样写会匹配Frist或1st 如果去掉,则 Fri|1st就是匹配 Fri或1st2、将若干个字符进行组合,受量词的同时作用。例如 th+ 表示匹配 th thh thhh(h无数次),如果是(th)+,则匹配的是th thth ththth(th无数次)3、反向引用,即前面括号匹配到的东西记忆...转载 2018-12-03 11:14:57 · 297 阅读 · 0 评论 -
正则表达式-验证是否是6位数字
Regex regex = new Regex(@"^\d{6}$", RegexOptions.ECMAScript); while (true) { Console.WriteLine("请输入一个字符串"); string postcode = Console.ReadLine(...原创 2018-12-03 11:14:51 · 12926 阅读 · 0 评论 -
C#修改string的内容
namespace 字符串的本质{ class Program { static void Main(string[] args) { string s = "xiaosage"; //string是不可改变的,需转换成字符型数组再做改变。 char[] chs= s.ToC...原创 2018-12-03 11:14:41 · 1621 阅读 · 0 评论 -
c#学习笔记之EF基本操作
一、平台windows7 64bit、Sql server2012、vs2013二、目标学习c# EF的最最基本的CRUD操作三、用sql server2012创建数据库和student表(略过)四、用VS2013新建控制台项目五、创建EF实体数据模型1.右键单击VS右侧的控制台项目,添加、新建项、选中左侧C#, 中间选中“ADO.NET实体数据模型”。2....原创 2019-05-30 14:57:47 · 5401 阅读 · 0 评论 -
C#笔记之MVC中ViewData传对象到视图
一、目标在C# MVC开发模式下了解ViewData怎么讲一个List<Model>传到前台,并且前台怎么循环读取出数据二、平台vs2013, MVC模式三、重要部分控制器代码展示 #region 5.PC详情页 public ActionResult PcDetail() { string pcUID = ...原创 2019-07-02 17:04:59 · 3397 阅读 · 0 评论 -
c# mvc视图的foreach使用方法和foreach索引值
一、目标在C# MVC开发模式下了解前台foreach循环读取对象,并加索引值二、平台vs2013, MVC模式三、重要部分控制器代码展示1.Controller中主要代码 #region 7.测试 public ActionResult test() { PcBLL pcbll = new PcBLL(); ...原创 2019-08-21 16:36:55 · 7999 阅读 · 0 评论 -
C#递归删除指定文件夹下的所有东西
一、目标在C# 删除指定文件夹下的所有文件、子文件夹、空文件夹。二、平台vs2013, MVC模式三、重要部分控制器代码展示1.删除文件夹方法,接收一个文件夹路径#region 9.删除/upload/kahnFolder/文件夹下的所有内容 public void deleteUploadOaFolder(string folderPath) ...转载 2019-08-21 16:49:03 · 845 阅读 · 0 评论 -
c#正则表达式之从不规则日期中提取年月日
#region 10_从不规则日期中提取年月日。 string xdate = "August 17 , 2016 "; Match xMatch = Regex.Match(xdate, @"^([a-zA-Z]+)\s*(\d{1,2})\s*,\s*(\d{4})\s*$"); Console.Write...原创 2018-12-03 11:15:32 · 3917 阅读 · 0 评论 -
c#正则表达式之替换01
#region 11_正则表达式之替换01 string msg = "马aaa荣aaaaaaa现代aaa社会潘aaa金a莲"; msg = Regex.Replace(msg, "a+", "A"); Console.WriteLine(msg); Console.ReadKey(); ...原创 2018-12-03 11:15:39 · 3569 阅读 · 0 评论 -
C# MVC 首页列表action
1.action写法: #region 列表首页 public ActionResult Index() {YunWeiEntities db = new YunWeiEntities(); return View(db.vpnuserinfotest1.ToList()); } #endr...原创 2018-11-21 13:27:19 · 435 阅读 · 1 评论 -
C# EF+Linq & Lambda多条件查询语句
1.Linq单条件查询var xxfDate = from u in dbContext.Customer where u.Id > 0 select u.CusName; 2.Linq多条件查询var xxfDate = from u in dbContext.Cus...原创 2018-11-21 13:27:48 · 8148 阅读 · 1 评论 -
C# EF+Linq分页
数据库表名Customer。var demo = (from u in dbContext.Customer where u.Id > 0 orderby u.Id //默认升序ascending,降序descending select u...原创 2018-11-21 13:28:21 · 1306 阅读 · 1 评论 -
c# Lambda+EF分页
#region 分页//数据库表名Customer var pageDate = dbContext.Customer .Where(u => u.Id > 0) //.OrderByDescending(u => u.Id) //根据ID排列,降序排列 ....原创 2018-11-21 13:28:56 · 2134 阅读 · 1 评论 -
C# sql linq lamda写法
在数据库Customer中查询id>1的所有信息1.Lamda表达式:var data = dbContext.Customer.Where(u=>u.Id>1); foreach (var item in data) { Console.WriteLine(item.Id+" " +i...原创 2018-11-21 13:29:42 · 466 阅读 · 1 评论 -
c# SqlHelper
using System;using System.Collections.Generic;using System.Configuration;using System.Data;using System.Data.SqlClient;using System.Linq;using System.Text;using System.Threading.Tasks;namesp...转载 2018-11-21 13:31:07 · 1755 阅读 · 0 评论 -
c#连接mssql数据库笨方法
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.T...原创 2018-11-22 11:33:55 · 771 阅读 · 0 评论 -
C#委托介绍
一、介绍1.新建两个控制台程序【委托01、委托02】(引用下面的class1.cs)2.新建一个类文件class1.cs3.在class1.cs下新建一个类,名字如T1Delegate的委托。 二、程序1.委托01using System;using System.Collections.Generic;using System.Linq;using Syste...原创 2018-11-22 13:28:58 · 116 阅读 · 0 评论 -
C#委托介绍2
1.类文件using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ClassLibrary2{ public class Class1 { public dele...原创 2018-11-22 14:22:13 · 99 阅读 · 0 评论 -
16_C#正则表达式之06将邮箱中的名字替换成星号
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Text.RegularExpressions;using System.Runtime.Serialization.Formatters...原创 2019-06-10 23:09:23 · 876 阅读 · 0 评论 -
c#正则表达式之替换05将一段URL字符串替换成html代码
#region 15_c#正则表达式之替换05将一段URL字符串替换成html代码 string msg = "美女车模网的网址是: http://www.meinvchemo.com, 还有IBM网的网址是: http://www.hiibm.com . hoho"; msg = Regex.Replace(msg, "([a-zA-Z]+:/...原创 2019-06-10 23:09:13 · 348 阅读 · 0 评论 -
c#正则表达式之替换04替换手机号的掩码
#region 14_c#正则表达式之替换04替换手机号的掩码 string xmsg = "我的手机号码是13802188888,我的第二个手机号码是13888888888这个手机号码够屌吧,你搜到这个网页说明你也够无聊了,但还是祝你早日发财。"; xmsg = Regex.Replace(xmsg, @"(\d{3})(\d{4})(\d{4}...原创 2019-04-02 16:43:16 · 1045 阅读 · 0 评论 -
c#正则表达式之替换03
#region 13_正则表达式之替换03 //将'ma rong' is xiandai shehui '潘a金莲'.替换为【ma rong】 is xiandai shehui 【潘a金莲】. string xmsg = "'ma rong' is xiandai shehui '潘a金莲'"; xmsg = Regex...原创 2019-07-27 09:16:59 · 224 阅读 · 0 评论 -
c#正则表达式之替换02
#region 12_正则表达式之替换02 string xmsg = "马荣宋哲是08/01/2016年私奔的,08/13/2016王开始诉讼的,希望狗男女01/31/2017被法半"; xmsg = Regex.Replace(xmsg, @"(\d{2})/(\d{2})/(\d{4})","$3年$1月$2日"); ...原创 2018-12-03 11:16:04 · 608 阅读 · 0 评论 -
C#计算月的最后一天
//-------------------试用期计算开始---------------------------- DateTime tStart = DateTime.Parse("2013/6/27 0:00:00"); int qiXian = 3; DateTime tEnd = tStart.AddDays(1 - t...转载 2018-09-02 22:34:51 · 429 阅读 · 0 评论