码迷,mamicode.com
首页 > Windows程序 > 详细

C# join和split

时间:2015-06-10 13:49:48      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

string[] parts = { "A", "B", "C", "D", "E" };
string result = string.Join(",", parts);
Console.WriteLine(result);
for (int i = 0; i < result.Split(‘,‘).Length; ++i)
{
    Console.WriteLine(result.Split(‘,‘)[i]);
}
以后拼接json终于不用写if了

放一个看到的找IP4的函数,在存在多个IP4的时候有问题
public string GetIP_4()
{
    string restr = "";
    IPAddress[] ipList = Dns.GetHostAddresses(Dns.GetHostName());
    foreach (IPAddress ip in ipList)
    {
        //获得IPv4                
        if (ip.AddressFamily == AddressFamily.InterNetwork)
        {
            restr = ip.ToString();
            //if (restr.Length >= 9)
            //    break;
        }
    }
    return restr;
}
 

C# join和split

标签:

原文地址:http://www.cnblogs.com/wish198/p/4565597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!