C#String类用法之String.LastIndexOf 方法

//
        // 摘要:
        //     报告指定字符串在此实例中的最后一个匹配项的从零开始的索引的位置。
        //
        // 参数:
        //   value:
        //     要搜寻的字符串。
        //
        // 返回结果:
        //     如果找到该字符串,则为 value 的从零开始的起始索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为此实例中的最后一个索引位置。
        //
        // 异常:
        //   T:System.ArgumentNullException:
        //     value 为 null。
        public int LastIndexOf(String value);
Models.DBEntityModel.PrinttemplateModel resultPrintTemplate = Models.DBEntityModel.PrinttemplateModel.GetDefaultPrintTemplate((int)ReportTypeEnum.ResultReport);
            string sourceFilePath = resultPrintTemplate.SourcePath;
            if (resultPrintTemplate.ID <= 9)
            {
                int lastFlag = resultPrintTemplate.SourcePath.LastIndexOf(@"");
                sourceFilePath = resultPrintTemplate.SourcePath.Substring(lastFlag);
                sourceFilePath = AppDomain.CurrentDomain.BaseDirectory + "Report" + sourceFilePath;
            }

报告指定 Unicode 字符或字符串在此实例中的最后一个匹配项的从零开始的索引的位置。 如果未在此实例中找到该字符或字符串,则此方法返回 -1。

相关推荐: C#方法和委托的重载必须一致。传参类型都为int,uint报错

   今天工作中遇到问题,出现了System.ArgumentException:“无法绑定到目标方法,因其签名或安全透明度委托类型的签名或安全透明度不兼容。”这个错误有时是因为重载的方法相关推荐: C#方法和委托的重载必须一致。传参类型都为int,uint…

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容