
重拾c#
钟眞龙
用尽一切合法合理合德的手段进步进步
展开
-
【精通C#】第一章 .NET之道
C#和.NET没出生之前,Windows操作系统上的开发们常常使用COM编程模型:COM,即Component Object Model,组件对象模型。允许个人构建可以由不同语言共享的代码库。比如,Visual Basic开发者可以使用C++程序员构建的COM库(不是很理解,这个现在C#调用C++库有啥区别吗?)。优点:语言无关缺点:基础结构复杂、部署模型脆弱,只能部署在windo...原创 2019-10-17 19:42:23 · 330 阅读 · 0 评论 -
无法将类型为“System.Xml.XmlComment”的对象强制转换为类型“System.Xml.XmlElement”。---C#
最近自己负责维护的一个软件出现了如下错误:Exception: 无法将类型为“System.Xml.XmlComment”的对象强制转换为类型“System.Xml.XmlElement”。收到产品线发来的bug通知,我很快就意识到了在什么地方出错。之前公司软件升级时,有一个xml文件需要我们plc这边负责升级(由原来的lua文件格式转为xml格式)。解析xml的代码部分如下: va...原创 2019-02-19 18:58:55 · 3075 阅读 · 1 评论 -
c#之string的格式化字符串format
string库的format函数是用来格式化其用法如下using System;using System.Text;namespace Excise1{ public class Program { public static void Main(string[] args) { Enco原创 2017-04-27 13:45:24 · 935 阅读 · 0 评论 -
c#之string类型的一些常用库函数
string a = "rerrreafshgtjhtr"; int pos=a.IndexOf('a'); Console.WriteLine(pos); 输出pos=6; indexOf('字符')或者indexOf("字符"):用于获取某个字符在字符串中首次出现的位置 Substring(int s原创 2017-04-21 21:33:39 · 1606 阅读 · 0 评论 -
C#之引用 ref
目前没有深究,和c++用法一样,在代码编写过程中发现,在主函数之外写函数需要声明成为static类型的,否则编译不通过,真是蛋疼using System;using System.Text;namespace Excise1{ public class Program { public class Student {原创 2017-04-21 21:08:42 · 501 阅读 · 0 评论 -
C#之类私有成员的安全访问
当类内声明了private 成员的时候,外面对这个是禁止访问的,之前学的C++是通过添加访问函数和更改函数来对其进行更改和访问,现在c#的set 和get 方法一个道理set 方法里面有个value,就是对应的字段的值,比如说private string age ,对应的set 函数是 set string Age{age =value;} 当然我们也可以自定义Age函数体。这样一来外界原创 2017-04-21 20:49:40 · 611 阅读 · 0 评论 -
C#之foreach循环
C#的foreach循环,就是定义相同类型的某个变量,然后逐个去读取数组或者集合里面的值using System;using System.Text;namespace Excise1{ public class Program { public static void Main(string[] args) {原创 2017-04-21 20:14:54 · 763 阅读 · 0 评论 -
C#之数组定义
c#数组定义与以往学的c和c++有点区别,而且new之后不用deleteusing System;using System.Text;namespace Excise1{ public class Program { public static void Main(string[] args) {原创 2017-04-21 20:04:15 · 1928 阅读 · 0 评论 -
C#之Switch分支语句
C#的Switch选择分支语句在每个case语句后要加break;否则会编译不通过using System;using System.Text;namespace Excise1{ public class Program { public static void Main(string[] args) {原创 2017-04-21 19:46:14 · 585 阅读 · 0 评论 -
hello world C#
最近参加微软的编程之美比赛,需要用到c#知识,大二下学过,不过最近看起代码来有点吃力,所以打算重拾c#using System;using System.Text;namespace Excise1{ public class Program { public static void Main(string[] args)原创 2017-04-21 19:19:40 · 615 阅读 · 0 评论 -
.net core窗口输出中文乱码解决方案
.net core 真坑居然没有直接注册gb2312编码跟着百度上面的一些做法改cmd的编码页默认值等一系列操作不能成功,后来发现这篇博文才解决此方案需要在console.write(); 之前导入某个相关的包加 上这行注册码Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);然后解决窗原创 2017-04-20 14:42:37 · 4075 阅读 · 1 评论