Split out ints from string

前端 未结 13 1362
情歌与酒
情歌与酒 2021-01-17 17:45

Let\'s say I have a web page that currently accepts a single ID value via a url parameter:
http://example.com/mypage.aspx?ID=1234

I want to change it to acce

13条回答
  •  攒了一身酷
    2021-01-17 18:06

    To continue on previous answer, quite simply iterating through the array returned by Split and converting to a new array of ints. This sample below in C#:

            string[] splitIds = stringIds.Split(',');
    
            int[] ids = new int[splitIds.Length];
            for (int i = 0; i < ids.Length; i++) {
                ids[i] = Int32.Parse(splitIds[i]);
            }
    

提交回复
热议问题