.Net

C#判断某元素是否存在数组中

  strings="K2:CENTALINE\lukshing|K2:CENTALINE";string[]s1=s.Split('|');//判断方式是等于而不是LikeConsole.WriteLine(Array.IndexOf(s1,"K2:CENTALINE"));//0存在这个是在vs...

C# 做的Windows 应用程序 服务

运行服务:1,cmd下进入目录cdC:WindowsMicrosoft.NETFrameworkv4.0.303192,安装服务installutilF:中原集团天津CCHRrunkcchrrunkCCOOBOCCHR.WorkFlowReminderWathcerinDebugCCHR.WorkFlowRemind...

C# 特性篇 Attributes

 特性[Required](必修的)///<summary>///操作人EmpID///</summary>[Required]publicstringOptEmpID{get;set;}//验证方式if(!ModelState.IsValid){  StringBuildererri...
IT猿·2020-03-28

C# 模型赋值

///<summary>///模型赋值///</summary>///<paramname="target">目标</param>///<paramname="source">数据源</param>publicstaticvoidCopyModel...
IT猿·2020-03-28

.net core 使用 swagger 生成接口文档

微软参考文档:https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual-studio在 .netcore 中使用 swagger 生成接口...

C#中dynamic的正确用法

dynamic是FrameWork4.0的新特性。dynamic的出现让C#具有了弱语言类型的特性。编译器在编译的时候不再对类型进行检查,编译期默认dynamic对象支持你想要的任何特性。比如,即使你对GetDynamicObject方法返回的对象一无所知,你也可以像如下那样进行代码的调用,编译器不会报错:dynami...

Asp.net mvc中Controller的返回值

(1)EmptyResult:当用户有误操作或者是图片防盗链的时候,这个EmptyResult就可以派上用场,返回它可以让用户啥也看不到内容,通过访问浏览器端的源代码,发现是一个空内容;publicActionResultEmptyResult(){//空结果当然是空白了!//至于你信不信,我反正信了returnnew...

asp.net获取文件夹下的所有文件

usingSystem;usingSystem.Collections.Generic;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.IO;publicpartialclassadmin_Default:Sys...

.net Core中如何读取Appsetting配置文件

 现在APPSetting下面配置以下节点{"Logging":{"IncludeScopes":false,"LogLevel":{"Default":"Warning"}},"ConnectionStrings":{"Conn":"Host=10.10.1.15;Port=5432;Database=po...

.Net Core api 中获取应用程序物理路径wwwroot

如果要得到传统的ASP.Net应用程序中的相对路径或虚拟路径对应的服务器物理路径,只需要使用使用Server.MapPath()方法来取得Asp.Net根目录的物理路径,如下所示://ClassicASP.NETpublicclassHomeController:Controller{publicActionResul...

C# 接口(interface) 抽象类(abstract)

类代码:interfaceEmployee{voidShowEmp();}abstractclassEmployeeInPostion:Employee{publicabstractvoidShowEmp();}classEmployeeInPass:Employee{publicvirtualvoidShowEmp(...

C# Base64方式的编码与解码

编码与解码方法:///编码publicstaticstringEncodeBase64(stringcode_type,stringcode){stringencode="";byte[]bytes=Encoding.GetEncoding(code_type).GetBytes(code);try{encode=Co...

C# 获取枚举的描述Description

方法类:publicstaticclassEnumExtensions{#regionEnum///<summary>///获取枚举变量值的Description属性///</summary>///<paramname="obj">枚举变量</param>///<r...

C# @string $string $@string

@string 保证换行后也属于同一个字符串 (请特别注意这样也会直接输入,不在起到换行的效果)stringexecSql=@"SELECT  T1.ProcInstID,T1.Folio,T1.ApplyID,T2.RowID,T2.CurWorkFlowStep,T2.CurAuditor,T2...
IT猿·2020-03-28

.NET中一些关键词的意义

constintx=0;publicconstdoublegravitationalConstant=6.673e-11;privateconststringproductName="VisualC#"; 就是说viewstate中存的数据只能在声明该变量的页面中使用.比如在某页的page_load中声明了:...