string split in c#

后端 未结 2 1730
遥遥无期
遥遥无期 2020-12-12 01:17

I have strings like this:

    00123_MassFlow
    0022245_VOlumeFlow
    122_447_Temperature

I have to split these strings with _

2条回答
  •  自闭症患者
    2020-12-12 02:04

    "122_447_Temperature".Split('_').Last();
    

    If you don't mind the extra overhead of creating an array and throwing away a bunch of strings. It won't be as fast as using LastIndexOf and Substring manually, but it's a ton easier to read and maintain, IMO.

提交回复
热议问题