将字符串值转换为int [英] convert string value to int

查看:93
本文介绍了将字符串值转换为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个变量

string tabtype =,7,11;



int Company = tabtype;





如何将字符串值转换为int

解决方案

嗨Sanjay,



在ypur tabtaype中你有一个逗号分隔的字符串。因此,在拆分后,您将获得一个整数数组。例如:

  string  tabtype =  ,7,8,11; 
int [] nums = Array.ConvertAll(tabtype.Remove( 0 1 )。分割(' ,'),< span class =code-keyword> int .Parse);





您现在拥有一系列公司。循环使用这些ID。



希望这有帮助! :) :)







问候,

Praneet


  string  tabtype =   7,11\" ; 

string [] num = tabtype.Split(' );

int a = int .Parse(num [ 0 ]);


i have two varible
string tabtype=,7,11;

int Company=tabtype;


how to convert string value to int

解决方案

Hi Sanjay,

In ypur tabtaype you have a comma seperated string. So after splitting you will get an array of integers. Like:

string tabtype = ",7,8,11";
int[] nums = Array.ConvertAll(tabtype.Remove(0, 1).Split(','), int.Parse);



You now have an array of Company. Loop this and use these ids.

Hope this helps !! :) :)



Regards,
Praneet


string tabtype = "7,11";

string[] num = tabtype.Split(',');

int a = int.Parse(num[0]);


这篇关于将字符串值转换为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆