版权声明:欢迎转载,欢迎讨论,大家一起共同进步!呵呵哒~ https://blog.csdn.net/lyh916/article/details/52054682
参考链接:
http://www.xuanyusong.com/archives/3940
http://www.xuanyusong.com/archives/3971
http://blog.csdn.net/he_wen_jian/article/details/41011475
一.说一下下面几个东西的区别:
\r:ascii码表中的13号,表示光标移向最左侧
\n:ascii码表中的10号,表示光标移向下一行
在windows中,回车是\r\n
在unix和liunx中,回车是\n
因此,如果在WIndow下对CSV文件进行按行分割,那么就是:字符串.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);//按行分割
测试如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharp_ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//1
//Console.Write("abcd\r123");
//2
//Console.Write("abcd\n123");
//3
//Console.Write("abcd\r\n123");
//4
string s = "abcd\r\n123";
string[] s2 = s.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
Console.Write(s2[0]);
Console.Write("abcd");
Console.Write(s2[0].Equals("abcd"));
Console.Read();
}
}
}
分析:虽然2和3的效果看起来是一样的,但是2确实比3少了一个\r。分析一下4,先输出abcd\r,此时光标移到开头,然后输出abcd,覆盖了原来的。
二.数组和字典的值复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharp_ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//1.数组值复制
int[] a = new int[]{1, 2, 3, 4};
int[] b = new int[a.Length];
Array.Copy(a, b, a.Length);
//输出1234
for (int i = 0; i < b.Length; i++)
{
Console.Write(b[i]);
}
a[0] = 11; a[1] = 22; a[2] = 33; a[3] = 44;
//输出1234
for (int i = 0; i < b.Length; i++)
{
Console.Write(b[i]);
}
Console.WriteLine();
//2.字典值复制
Dictionary<string, int> c = new Dictionary<string, int>();
c.Add("a", 100);
c.Add("b", 200);
Dictionary<string, int> d = new Dictionary<string, int>(c);
//输出key = 100, value = 200
foreach (var item in d)
{
Console.WriteLine("key = {0}, value = {1}", item.Key, item.Value);
}
c["a"] = 300;
c["b"] = 400;
//输出key = 100, value = 200
foreach (var item in d)
{
Console.WriteLine("key = {0}, value = {1}", item.Key, item.Value);
}
Console.Read();
}
}
}
三.转换工具说明
相对于参考链接的:
优点:
1.支持中文
2.纯c#编写,修改起来很方便
缺点:
1.只能导出c#类和二进制文件
2.只能在编辑器中使用,当然可以通过第三个参考链接导出可用的exe版本
四.excel相关
1.添加和编辑批注:shift+F2
2.显示所有批注:审阅 / 显示所有批注
下载地址:
http://pan.baidu.com/s/1dFlwRAx