
C#
Daniel799
DXC.technology
展开
-
SMTP 发送邮件
public void SendEmail(string smtpServer, string mailFrom, string userPassword, string mailTo, string mailSubject, string mailContent) { // 邮件服务设置 SmtpClient smtpClient = new SmtpClient(); smtpClient.Deli...原创 2020-08-20 14:13:02 · 1062 阅读 · 0 评论 -
c# 密码生成器 数字和字母
c# 生成数字字母组合密码原创 2020-08-13 11:58:41 · 637 阅读 · 0 评论 -
C# AutoFac 依赖注入
依赖注入:A Class 依赖B Class。B Class 是接口C的实现。在A中对C进行依赖注入,注入方法使用构造函数。通过AutoFac实现B Class注入到C。结果:A只与C有依赖关系,与B没有。在A中实现对接口的编程。通过AutoFac可以调整B Class,此时A的代码不需要做变动。Demousing System;using Class...原创 2020-03-22 17:24:15 · 1243 阅读 · 0 评论 -
C# Linq查询 XML Object
Demo using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Xml.Linq;namespace LinqDemo{ class Program { ...原创 2018-10-09 17:56:49 · 820 阅读 · 0 评论 -
C# 可选参数与命名实参
Demo using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace OptionParameters{ class Program { static void...原创 2018-10-09 19:22:26 · 452 阅读 · 0 评论 -
HTML+ashx提交表单
将Form表单序列化为数组,然后转换为对象,通过json的方式传到后台。后台将接收到的json反序列化。该方式的优点是直接将Form表单的内容整体打包提交。HTML代码:<!DOCTYPE html><html><head> <meta charset="utf-8" /> <script type="text/j...原创 2019-04-01 09:10:16 · 1058 阅读 · 0 评论 -
C# 生成Word文件(图片,文字)
通过Microsoft.Office.Interop.Word生成Word文档1.引用类 WordReport.cs,代码如下:using System;using System.Collections.Generic;using System.Text;using Microsoft.Office.Interop.Word;using MSWord = Microsoft.Of...原创 2019-05-21 18:28:08 · 4533 阅读 · 1 评论 -
C# 删除文件夹,删除文件
public void Clear_Files(string path) { if (Directory.Exists(path)) { //获取该路径下的文件路径 string[] filePathList = Directory.GetFiles(p...原创 2019-05-21 18:33:50 · 8162 阅读 · 0 评论 -
C# 获取文件夹,获取文件
public void GetDirectories() { string path=@"c:\\temp\\"; //如果该路径不存在,就创建该路径。 if (!Directory.Exists(path)) Directory.CreateDirectory...原创 2019-05-21 19:07:05 · 2785 阅读 · 0 评论 -
C# 创建log日志
/// <summary> /// /// </summary> /// <param name="message">log 信息</param> /// <param name="path">log 路径 </param> //...原创 2019-05-21 19:13:14 · 3145 阅读 · 0 评论 -
C# Extension Method 扩展方法
扩展方法是C# 3.0的新特性。它为现有的类型添加方法,从而解决了使用继承扩展所带来的所有弊端。Demo 1 简单的扩展方法using System;namespace ExtensionMethod{ class Program { static void Main(string[] args) { st...原创 2018-09-27 20:05:12 · 2011 阅读 · 0 评论 -
C# Data Type 数据类型
装箱与拆箱Demousing System;namespace Boxing{ class Program { static void Main(string[] args) { int i = 3; //装箱,隐式转换 object o = i; ...原创 2018-09-21 20:01:37 · 3149 阅读 · 0 评论 -
c# 自动实现属性 隐式类型 对象及集合初始化 匿名类型
Demo using System;using System.Collections.Generic;namespace IntelligentCompiling{ class Program { static void Main(string[] args) { //隐式类型数组 v...原创 2018-09-26 17:57:16 · 707 阅读 · 0 评论 -
C#创建日志(LOG)
public void Log(string message) { try { string logFileName = "c:\\log\\LogName" + DateTime.Now.ToString("yyyy-MM-dd") + ".log"; ...原创 2018-08-21 15:11:05 · 3778 阅读 · 0 评论 -
C# Web Service & Interface Introduction
一 Web Service的创建1.在WebApplication下创建WebService2.创建Request类与Response类,用于传参和返回参数。Request是接口参数,在对方调接口函数时填写的参数。Response是接口函数的返回值,一般返回接口执行状态和对应的信息。using System;using System.Collections.Generic...原创 2018-08-31 18:37:06 · 251 阅读 · 0 评论 -
C# DropdownList Item设置与数据绑定
1.DropDownList Item protected void leadGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ...原创 2018-08-29 17:46:14 · 2477 阅读 · 0 评论 -
SQL 数据库操作Utility
using System.Collections.Generic;using System.Text;using System.Data;using System.Data.SqlClient;using System.Collections;using System.Xml;using System;namespace Utility{ /// 此类为抽象类, ...原创 2018-09-19 14:41:30 · 521 阅读 · 0 评论 -
C# Delegate & DelegateChain
Delegate IntroductionDemo1 Delegateusing System;using System.Collections.Generic;using System.Text;namespace ConsoleDelegate{ class DelegateDemo { //申明一个返回类型是void,有一个String...原创 2018-09-19 14:38:07 · 166 阅读 · 0 评论 -
C# Heap and Stack 堆栈
转载 https://www.cnblogs.com/MaxJoker/p/5652092.html原创 2018-09-25 11:38:22 · 250 阅读 · 0 评论 -
C# Event
Key Point Demo using System;namespace EventDemo{ public class Program { static void Main(string[] args) { Friend f1 = new Friend("Alen"); Frie...原创 2018-09-19 19:42:17 · 1826 阅读 · 0 评论 -
C# Parameter Passing 参数传递
原创 2018-09-25 12:25:45 · 582 阅读 · 0 评论 -
C# 泛型 Generic
Demo using System;namespace GenericDemo{ class Program { static void Main(string[] args) { Console.WriteLine(Compare<int>.CompareGeneric(3, 4)); ...原创 2018-09-25 16:03:35 · 162 阅读 · 0 评论 -
C# 可空类型 匿名方法 迭代器
可空类型Demousing System;namespace NullDemo{ class Program { static void Main(string[] args) { //?语法糖 DateTime? date= null; int? a = nul...原创 2018-09-25 18:59:34 · 206 阅读 · 0 评论 -
将xml格式的string格式化,方便阅读。
public XmlDocument GetXmlDocument(string xmlString) { XmlDocument document = new XmlDocument(); document.LoadXml(xmlString); return document; ...原创 2018-08-21 15:03:56 · 3177 阅读 · 2 评论