![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C#
飞翔精灵
这个作者很懒,什么都没留下…
展开
-
When To Use IEnumerable, ICollection, IList And List
I think that the question when to use IEnumerable, ICollection, IList or List is a common one that hasn’t often being answered in an easy way. I not only want to do this within this article, but I als...转载 2018-06-01 15:32:02 · 326 阅读 · 0 评论 -
WCF学习心得----(五)生成客户端
WCF学习心得----(五)生成客户端1. 通过Svcutil.exe工具直接生成客户端1.1 将服务承载于IIS上1.1.1 在IIS中新建网站,所示效果如下图:1.1.2 新建WCF应用程序,项目文档结构如下图:1.1.3 选中项目,点击右键在资源管理其中打开文件,结构如下:将上图中红框标记的文件拷贝至跟网站虚拟目录映射的物理路径下,一般都是在C盘,如下路径转载 2014-09-03 15:28:44 · 927 阅读 · 0 评论 -
WCF学习心得------(一)什么是WCF
什么是WCF什么是WCF?提供统一的,可用于建立安全、可靠的面向服务的应用的高效开发平台。将web服务的概念直接映射到.NET Framework公共语言运行库(CLR)中对应的内容,包括将消息灵活且可扩展的映射到注入VisualC#等语言实现的服务。该服务模型提供支持松散耦合和版本管理的序列化功能,并提供与注入消息队列(MSMQ),COM+,ASP.NETweb服务、Web服务增强(转载 2014-09-03 15:22:31 · 644 阅读 · 0 评论 -
Why "using" may play tricks on your WCF service host
Many of the examples that have been published on the web about hosting the WCF use the "using" block to initialize the service. This blog entry shows you why this can catch you.The problem arises wh转载 2014-09-03 14:13:20 · 595 阅读 · 0 评论 -
WCF使用小结:(1)WCF接收HTTP POST数据的处理方法
在WCF 4.0中,为我们创建Restful API有了更好的支持。通过定义UriTemplate,WebInvoke就可以快速开发API接口。这里我记录一下HTTP POST数据时要如何接收POST过来的数据。1,方法一:Stream inputStream 输入流方法(注意看方法例如我的代码转载 2014-09-03 09:06:01 · 12899 阅读 · 0 评论 -
WCF学习心得------(三)配置服务
配置服务 配置服务概述 在设计和实现服务协定后,便可以进行服务的配置。在其中可以定义和自定义如何向客户段公开服务,包括指定可以找到服务的地址,服务用于发送和接受消息的传输和消息编码,以及服务需要的安全类型。配置服务类型使用配置文件配置1) 使用配置文件配置WCF服务,可提供在部署时而非设计时提供终结点和服务行为数据的灵活性2) 可以使用.NET Framework配置技术对转载 2014-09-03 15:24:25 · 656 阅读 · 0 评论 -
WCF学习心得----(四)服务承载
WCF学习心得----(四)服务承载这一章节花费了好长的时间才整理个大概,主要原因是初次接触这个东西,在做练习实践的过程中,遇到了很多的问题,有些问题到目前还没有得以解决。所以在这一章节中,有一个承载是没有例子的。仍在努力解决所在的问题,后续会把例子给补上的。好了,进入正题。要变为活动状态,服务必须承载于创建它并控制它的上下文和生存周期的运行环境中。WCF有以下三种承载方式:在IIS中承载转载 2014-09-03 15:27:45 · 762 阅读 · 0 评论 -
WCF学习心得------(二)设计和实现服务协定
设计和实现服务协定创建服务协定—WCF术语消息消息是一个独立的数据单元,它可能由几个部分组成,包括消息正文和消息头。服务服务是一个构造,它公开一个或多个终结点,其中每个终结点都公开一个或多个方法。终结点终结点是用来发送或接收消息(或执行这两种操作)的构造。终结点包括一个定义消息可以发送到目的地的位置(地址,一个描述消息如何发送的通信机制规范(绑定)以及对于可以再该位置发转载 2014-09-03 15:23:29 · 597 阅读 · 0 评论 -
文件处理01
1、c#根据绝对路径获取 带后缀文件名、后缀名、文件名。 string str =" F:\test\Default.aspx"; string filename = System.IO.Path.GetFileName(str);//文件名 “Default.aspx” string exten原创 2014-08-11 10:41:35 · 387 阅读 · 0 评论 -
TimeSpan
TimeSpan的用法TimeSpan是用来表示一个时间段的实例,两个时间的差可以构成一个TimeSpan实例,现在就来简单介绍一下几点重要的用法:a 先来介绍几个方法TimeSpan.Minutes(其他时间比如天数,小时数,秒数都一样的情况下得到的分钟数的差),其他的Hours,Second一样DateTime.Tick :是一个计时周期,表示一百纳秒,即一千万转载 2014-09-04 14:43:53 · 539 阅读 · 0 评论 -
WCF 传送二进制流数据 stream
WCF 支持传送二进制流数据,但有一定的限制。只有 BasicHttpBinding、WebHttpBinding、NetTcpBinding 和 NetNamedPipeBinding 支持传送流数据。流数据类型必须是可序列化的 Stream 或 MemoryStream。 传递时消息体(Message Body)中不能包含其他数据。 我们先看看下面的例子。注意将 B转载 2014-09-03 20:47:44 · 2098 阅读 · 0 评论 -
WCF碰到的一些问题
static ServiceHost myService = null; myService = new ServiceHost(typeof(Service1));myService.Open();问题1Service 'WcfServiceLibrary1.Service1' has zero application (non-infrastructure) endpoints转载 2014-09-03 09:54:45 · 746 阅读 · 0 评论 -
C#怎样获取当前月份的天数
方法一: //最有技术含量的一种 int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(DateTime.Now.Year ,DateTime.Now.Month);方法二://最奇怪的一种 DateTime d转载 2015-03-30 17:18:33 · 2376 阅读 · 0 评论 -
更新页脚合计值
场景描述:采用表头表体方式建立单据录入界面,表体金额字段在页脚显示合计,并自动更新至表头的金额字段。存在问题:1、虽然在CellValueChanged事件里有调用GridView.UpdateSummary()方法但是并未能产生预期的效果,只有在光标发生移动后才会更新合计值。2、最后一行删除时,不能反馈到表头金额合计。解决方法:1、在Grid_CellVa原创 2017-02-02 23:19:58 · 812 阅读 · 0 评论 -
Using x-www-form-urlencoded Content-Type in WCF
So we have a wcf restful web service configured with webHttpBinding and everything works fine with http get. If change it to Post and post something like variable1=1&variable2=2 in message body d转载 2016-09-01 11:19:13 · 1976 阅读 · 0 评论 -
How to define One-Many and One-One relationships
LINQ helps you define relationships using EntitySet and EntityRef. To understand how we can define relationships using LINQ, let’s consider the below example where we have a customer who can have ma转载 2016-05-19 18:33:15 · 554 阅读 · 0 评论 -
C# DateTime的 ParseExact和 TryParseExact 使用说明
最近需要把“20121010”转换为“2012-10-10”格式,直接用Convert.ToDateTime("20121010"),系统报错“未被识别的DateTime类型”。解决方法: 一、DateTime.ParseExact string str = "20121010"; IFormatProvider ifp = new CultureInfo("转载 2016-05-08 14:46:55 · 6826 阅读 · 0 评论 -
C# Dictionary 的几种遍历方法
Dictionary list = new Dictionary(); list.Add("d", 1); //3.0以上版本 foreach (var item in list) { Console.WriteLine(item.Key + ite转载 2016-04-11 21:34:41 · 759 阅读 · 0 评论 -
PictureEdit - How to display external images by providing links for them
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;原创 2015-12-25 16:07:00 · 660 阅读 · 0 评论 -
Insert Image into Record from Clipboard
private void simpleButton2_Click(object sender, EventArgs e) { gridView1.AddNewRow(); Image img = Clipboard.GetImage(); MemoryStream stream = new MemoryStream();原创 2015-12-25 15:41:59 · 474 阅读 · 0 评论 -
How to provide the capability to expand empty rows of a master view to be able to add child rows
To be able to expand empty rows, just enable the master view's OptionsDetail.AllowExpandEmptyDetails option. In this case, empty master rows will display a grayed out expand button, which can be转载 2016-01-19 10:04:42 · 621 阅读 · 0 评论 -
C#下载文件(TransmitFile/WriteFile/流方式)实例介绍
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.W转载 2015-12-15 12:23:34 · 1664 阅读 · 0 评论 -
How to merge grid cells
The sample illustrates the way to merge grid cells based on a custom-defined rule. To enable cell merging, it's necessary to set theGridView.OptionsView.AllowCellMerge property to true. If you翻译 2015-11-19 15:15:44 · 1022 阅读 · 0 评论 -
C#数字格式化
格式规范的完整形式:{index [,width][:formatstring]}index是此格式程序引用的格式字符串之后的参数,从零开始计数;width(可选) 是要设置格式的字段的宽度,width取正数表示结果右对齐,取负数表示结果左对齐;formatstring(可选),包含有关设置类型格式的格式说明。一.内置类型的字母格式1. E-科学计数法表示25000.ToStrin转载 2014-08-01 15:00:53 · 543 阅读 · 0 评论 -
利用SmtpClient发送邮件
1 163邮箱 HOST:smtp.163.compublic staticstring CreateTimeoutTestMessage(string server){ string Success = "发送成功"; try { string _to = "1035092449@qq.com";string _from = "young-20@163.com转载 2014-08-06 15:23:23 · 2820 阅读 · 0 评论 -
C#读取当前项目路径的方法
//获取包含清单的已加载文件的路径或 UNC 位置。public static string sApplicationPath = Assembly.GetExecutingAssembly ( ).Location;//result: X:/xxx/xxx/xxx.dll (.dll文件所在的目录+.dll文件名)//获取当前进程的完整路径,包含文件名(进程名)。string转载 2014-06-21 22:17:18 · 1566 阅读 · 0 评论 -
DataContext ConnectionString
public string ConnectionString { get { if (ConfigurationManager.ConnectionStrings["conn"] == null || String.IsNullOrEmpty(ConfigurationManager.ConnectionStrings["转载 2014-06-25 14:05:47 · 947 阅读 · 0 评论 -
LINQ to SQL语句之视图和继承支持
视图我们使用视图和使用数据表类似,只需将视图从“服务器资源管理器/数据库资源管理器”拖动到O/R 设计器上,自动可以创建基于这些视图的实体类。我们可以同操作数据表一样来操作视图了。这里注意:O/R 设计器是一个简单的对象关系映射器,因为它仅支持 1:1 映射关系。换句话说,实体类与数据库表或视图之间只能具有 1:1 映射关系。不支持复杂映射(例如,将一个实体类映射到多个表)。但是,可以将一个实转载 2014-06-25 17:37:13 · 442 阅读 · 0 评论 -
怎样在VS2010中打开vs2012的项目
VS2012中对C#的支持度非常好,不管是编写方便程度(不需要插件就能高亮代码及代码自动提示功能),还对MFC的一些功能优化很多。我们可以修改两个工程文件来把VS2012的工程文件一直到VS2010中去。首先当然是修改解决方案文件(.sln文件)。使用记事本打开,把里面的Microsoft Visual Studio Solution File, Format Version 12转载 2014-03-13 11:05:29 · 451 阅读 · 0 评论 -
Attach js from server side
On suggestion is to use GridButtonColumn instead of GridTemplateColumn and set its DataTextField to corresponding field name. And you can set its CommandName and ConfirmText property like below.ASPX原创 2013-08-13 13:12:33 · 1139 阅读 · 0 评论 -
Call JavaScript from server side
It is possible to execute a JavaScript from server-side code. In order to do this, make sure that the code is actually inserted on the page – the easiest way is to put a simple alert() and check if it原创 2013-08-13 13:03:15 · 638 阅读 · 0 评论 -
C# DataGridView显示行号的三种方法
方法一:网上最常见的做法是用DataGridView的RowPostPaint事件在RowHeaderCell中绘制行号:privatevoiddataGridView1_RowPostPaint(objectsender, DataGridViewRowPostPaintEventArgs e){try{e.Graphics.DrawString((e.RowIndex转载 2013-08-05 16:58:47 · 72778 阅读 · 10 评论 -
How to add row numbers to DataGridView
You can render row numbers for DataGridView and DataGridViewX by handling RowPostPaint event. Then you use following code:void DataGridViewRowPostPaint(object sender, DataGridViewRowPostPaintEvent转载 2013-08-05 17:43:25 · 1172 阅读 · 0 评论 -
怎样在VS2010中打开vs2012的项目
VS2012中对C#的支持度非常好,不管是编写方便程度(不需要插件就能高亮代码及代码自动提示功能),还对MFC的一些功能优化很多。我们可以修改两个工程文件来把VS2012的工程文件一直到VS2010中去。首先当然是修改解决方案文件(.sln文件)。使用记事本打开,把里面的Microsoft Visual Studio Solution File, Format Version 12转载 2013-07-26 16:22:07 · 811 阅读 · 0 评论 -
DevExpress xtraTabbedMdiManager控件双击关闭MDI标签页
DevExpress .net组件包中,有一个组件是xtraTabbedMdiManager,可以将MDI窗口显示为TabControl的样式,可以说非常实用。可惜的是,关闭标签页(即子MdiChild)不能通过双击来实现,这对于用惯了傲游等软件的朋友来说,有点不习惯。查看xtraTabbedMdiManager的事件,只有MouseDown,MouseUp等,并没有DoubleClick,好转载 2012-09-13 15:38:36 · 3156 阅读 · 0 评论 -
动态添加XtraTabControl详细设置
在使用DXperience开发winform过程中 也许你需要使用XtraTabControl代码动态添加XtraTabPage, 其实动态添加XtraTabPage 并不难 下面看下以下代码 基本实现了动态添加page功能 双击关闭Page的功能.以下是代码片段: /// /// 添加到Tab控件里 /// ///转载 2012-09-13 15:14:31 · 10848 阅读 · 0 评论 -
LINQ to SQL语句之运算符转换和ADO.NET与LINQ to SQL
运算符转换1.AsEnumerable:将类型转换为泛型 IEnumerable 使用 AsEnumerable 可返回类型化为泛型 IEnumerable 的参数。在此示例中,LINQ to SQL(使用默认泛型 Query)会尝试将查询转换为 SQL 并在服务器上执行。但 where 子句引用用户定义的客户端方法 (isValidProduct),此方法无法转换为 SQL。解决方法转载 2014-06-25 17:18:59 · 546 阅读 · 0 评论 -
Linq 日志输出
Log属性用于将SQL查询或命令打印到TextReader。此方法对了解 LINQ to SQL 功能和调试特定的问题可能很有用。 下面的示例使用Log属性在SQL代码执行前在控制台窗口中显示此代码。我们可以将此属性与查询、插入、更新和删除命令一起使用。//关闭日志功能//db.Log = null;//使用日志功能:日志输出到控制台窗口db.Log = Console.Out转载 2014-06-25 17:31:25 · 1328 阅读 · 0 评论 -
SqlMethods操作
在LINQ to SQL语句中,为我们提供了SqlMethods操作,进一步为我们提供了方便,例如Like方法用于自定义通配表达式,Equals用于相比较是否相等。Like自定义的通配表达式。%表示零长度或任意长度的字符串;_表示一个字符;[]表示在某范围区间的一个字符;[^]表示不在某范围区间的一个字符。比如查询消费者ID以“C”开头的消费者。var q = from c in转载 2014-06-25 16:39:00 · 1179 阅读 · 0 评论 -
最近写树的递归绑定写腻了,发现一篇好文章
由于前两个月加班,代码写的比较多,而且很多树的递归绑定,写的我不胜其烦,自己最后也写了一套通用方法,但今天看到这个仁兄的方法,自觉人家写的更抽象通用一些,仅做参考原文链接如下http://www.cnblogs.com/francisYoung/p/3383178.html封装一个通用递归算法,使用TREEITERATOR和TREEMAP来简化你的开发工作。转载 2014-06-21 22:15:49 · 469 阅读 · 0 评论