开发者

getting the numbers entered in textbox in an array

开发者 https://www.devze.com 2023-01-29 20:16 出处:网络
开发者_高级运维how can i get the numbers entered in textbox in an array. for example: user enter 33,21,5,8 in textbox

开发者_高级运维how can i get the numbers entered in textbox in an array.

for example:

user enter 33,21,5,8 in textbox

and i want to make an array with this numbers,how can i do it?thanks in advance


Int32[] numbers = textbox1.Text.Split(',').Select(s => Int32.Parse(s)).ToArray();

to get the first item, use following code:

Int32[] numbers = textbox1.Text.Split(',').Select(s => Int32.Parse(s)).ToArray();
Int32 firstNumber = numbers.First();


private static void ConvertStringToArray(string p)
{
string[] CardsToBeSortedArray = p.Split(',');
int[] IntCard = Array.ConvertAll<string, int>(CardsToBeSortedArray, delegate(string
card)
{
int result;
int32.TryParse(card, out result);
return result;
});
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号