[Unity技巧]CSV转换工具

参考链接:

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值