• .NET中Split分割用法


    实例代码:
    /// <summary>
    /// 截取格位置格号
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Window_SJ_Close(object sender, WindowCloseEventArgs e)
    {
    string thtext = string.Empty;//格位置
    string idtext = string.Empty;//格号
    string[] array = hfGridId.Text.TrimEnd(',').ToString().Split(',');//取到值去掉尾部逗号,按逗号分割
    for (int j = 0; j < array.Length; j++)
    {
    string[] ht= array[j].TrimEnd('|').ToString().Split('|');//内部按|分割后赋值
    thtext += ht[0]+"</br>";
    idtext += ht[1]+",";
    }
    hfGridId.Text = idtext;
     
    MessageBox_Ext("上架格号为:</br>" + thtext);
    }
     
    调用: 
    //判断格容量是否充足
    string[] array = hfGridId.Text.TrimEnd(',').ToString().Split(',');//调用分割出来的格号按逗号分割
    for (int j = 0; j < array.Length; j++)
    {
    tbl_Grids_Info GridInfo = tbl_Grids_Info.GetModel(int.Parse(array[j]));
    int restCnts = GridInfo.CAPACITY - GridInfo.FILECNTS;
    //判断格子是否还有剩余容量
    if (restCnts <= 0)
    {
    MessageBox_Ext("该档案格现有容量已满,请更换档案格");
    return;
    }
    //上架数量小于格子剩余容量,则把上架总数量赋值给上架循环次数
    int loopCount = 0;//上架循环次数
    if (checklist.Count < restCnts)
    {
    loopCount = checklist.Count;
    }
    //不足则把剩余容量赋值给上架循环次数
    else
    {
    loopCount = restCnts;
    }
    限定目的,能使人生变得简洁。
  • 相关阅读:
    linux系统性能监控常用命令
    如何在windows的DOS窗口中正常显示中文(UTF-8字符)
    在Windows的CMD中如何设置支持UTF8编码?
    设置cmd的codepage的方法
    Oracle字符集转换
    移动端跨平台开发的深度解析
    类型擦除是抽象泛型的实例化的过程
    FP又称为Monadic Programming
    深入剖析Swift性能优化
    真实世界中的 Swift 性能优化
  • 原文地址:https://www.cnblogs.com/lx07/p/6757381.html
Copyright © 2020-2023  润新知