【C# 截屏】教程文章相关的互联网学习教程文章

C# Linq中比较字符串使用 Equals 为什么报错【代码】【图】

今天同事问了我一个问题,像下面一样的代码为什么 s.BG_PriGroID 为null的时候报错objGroList = objGroList.Where(s => s.BG_PriGroID.Equals(pId)).ToList(); 虽然我一直没遇到这种错误,(因为我一直用的==,我不常用Equals比较字符串)但是我还是想知道为什么,然后我就找了一下微软的在线源码 https://referencesource.microsoft.com/查了一下String.Equals,发现实现是下面这个样子的publicoverridebool Equals(Object obj)...

C# 面向对象【代码】【图】

C# 面向对象 葫芦娃大战奥特曼 ----显示效果----- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApplication1 {class Monster{publicstring Name;publicint HP = 100;publicvoid Fight(Monster op){Console.WriteLine(Name+"开始攻击"+op.Name);op.HP-=10;}publicvoid Fight(Monster op,int blood ){Console.Write...

C#接口的使用场合,接口应用【代码】

当一个项目不断的扩大的时候,会面临的问题是不断的有以下情况;1、以前编写程序的人离职了,新来的程序员看不懂以前的程序,或者觉得以前的程序部够好,但又不希望删除;2、当实现第三方接口时,如:读写IC卡,以前用的是VB实现,现在改为C/C++了,而主程序有的C#;……以上的情况适合接口实现,开发思维如下。 //定义程序员接口interface IProgramer{//定义程序接口函数string LanguageCode();}//C/C++程序员实现class CProgr...

C# 下利用ICSharpCode.SharpZipLib.dll实现文件/目录压缩、解压缩

ICSharpCode.SharpZipLib.dll下载地址1、压缩某个指定文件夹下日志,将日志压缩到CompressionDirectory文件夹中,并清除原来未压缩日志。 #region 压缩logs文件夹下日志public static void CompresslogDic(){ try{string logFilePath = AppDomain.CurrentDomain.BaseDirectory + "logs";DirectoryInfo logsDic = new DirectoryInfo(logFilePath);FileInfo[] bipLog = logsDic.GetFiles();DateTime dt = DateTime.Now;Lis...

C# 学习之旅(1)【代码】【图】

第一, 输入输出流都来自控制台。 1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5 6namespace ConsoleApplication17{8class Program9 { 10staticvoid Main(string[] args) 11 { 12int year = int.Parse(System.Console.ReadLine()); 13int month = int.Parse(System.Console.ReadLine()); 14int day = int.Parse(System.Console.ReadLine()); 15int days = fun(year, month, ...

C# string和byte[]数组之间相互转换【代码】

原文地址:传送门string转byte[]:byte[] byteArray = System.Text.Encoding.Default.GetBytes ( str );byte[]转string:string str = System.Text.Encoding.Default.GetString ( byteArray );string转ASCII byte[]:byte[] byteArray = System.Text.Encoding.ASCII.GetBytes ( str );ASCII byte[]转string:string str = System.Text.Encoding.ASCII.GetString ( byteArray );原文:http://www.cnblogs.com/marvelousone/p/7596770.h...

C# 泛型【代码】

C# 泛型1.定义泛型类在类定义中包含尖括号语法,即可创建泛型类:1class MyGenericClass<T> 2{ 3//Add code 4 }其中T可以遵循C#命名规则的任意字符。T可以看作是成员变量的类型、属性或者方法的返回类型以及方法的参数类型等。例如: 1class MyGenericClass<T>2 {3private T obj;4public MyGenericClass(T item)5 {6 obj=item;7 }8public T Obj9 { 10get{ return obj; } 1112 } 13 } 注意事项:...

c# 文件或者文件夹改名的最简单方法【代码】

使用cmd命令 renProcess.Start( "cmd", "/C " + "ren f:\\first c code.txt zhou.txt"); 原文:https://www.cnblogs.com/simadi/p/9435868.html

C# - is

??Checks if an object is compatible with a given type.An is expression evaluates to true if the provided expression is non-null, and the provided object can be cast to the provided type without causing an exception to be thrown.The is keyword causes a compile-time warning if the expression is known to always be true or to always be false, but typically evaluates type compatibility at run time.The ...

C#中override和new修饰符的区别

(new)“隐藏”,(override)“覆盖”(重写)。不过要弄清楚这两个有什么区别确实也很难,因为子类在使用父类方法时根本看不出区别,子类不管父类是new了还是override了,用的都是父类方法。区别就在于,一个子类对象中,用父类类型指针去访问子类成员时有区别。如果是new的,那么父类的这个函数地址仍然保留着,同时又提供了一个新的子类的该函数入口地址。也就是说子类对象中同时保存了两个入口地址,父类的该函数地址被“隐藏”,...

C#单元测试【图】

什么叫单元测试(unit testing)?是指对软件中的最小可测试单元进行检查和验证。对于单元测试中单元的含义,一般来说,要根据实际情况去判定其具体含义,如C语言中单元指一个函 数,Java里单元指一个类,图形化的软件中可以指一个窗口或一个菜单等。总的来说,单元就是人为规定的最小的被测功能模块。单元测试是在软件开发过程中 要进行的最低级别的测试活动,软件的独立单元将在与程序的其他部分相隔离的情况下进行测试。步骤1、创...

转载 C# 开源框架(整理)

C# 开源框架(整理)http://www.cnblogs.com/gaoyuchuanIT/articles/5612268.htmlJson.NET http://json.codeplex.com/Json.Net 是一个读写Json效率比较高的.Net框架.Json.Net 使得在.Net环境下使用Json更加简单。通过Linq To JSON可以快速的读写Json,通过JsonSerializer可以序列化你的.Net对象。让你轻松实现.Net中所有类型(对象,基本数据类型 等)和Json的转换。 Math.NEThttp://www.mathdotnet.com/Math.NET的目标是为提供一款自身...

C# 使用FileUpload控件上传图片,将文件转换成二进制进行存储与读取【代码】【图】

状况描述:  需要上传文件,但是不想要保存到实体路径下,便可以用该功能来实现。 效果图:  点击【Upload】按钮,上传文件到数据库;  点击【Preview】,预览文件; 具体实现:  前台: 1 <tr>2 <td class="subject" nowrap="nowrap" align="right" style="width: 180px; text-align: right;"><%=Resources.WebResource.OE_ID_TYPE%>3 <!--ID Type-->4 :5 </td>6 <td style="color: #F90;"> ...

C#控制鼠标代码实例【代码】

1获得当前屏幕中鼠标的位置 int i = MousePosition.X;int j = MousePosition.Y; 这是control类中的方法。2移动鼠标首先引入dll [System.Runtime.InteropServices.DllImport("user32")] private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); const int MOUSEEVENTF_MOVE = 0x0001; const int MOUSEEVENTF_LEFTDOWN = 0x0002; const in...

C#AES加密【代码】【图】

今天写个接口,要求如下,需要对应的AES加密(128位),例子php的C#实现///<summary>/// AES 加密 输出hex格式///</summary>///<param name="str">明文(待加密)</param>///<param name="key">密文</param>///<returns></returns>publicstaticstring AesEncrypt(string str, string key){if (string.IsNullOrEmpty(str)) returnnull;Byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);System.Security.Cryptography.RijndaelMa...