C#中string与int的转换?

chaseismydream 2001-07-27 10:52:37
请问string 与int(long、double等)怎样转换?要用具体函数吗?哪个?
...全文
528 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
pie9912 2001-08-05
  • 打赏
  • 举报
回复
上面的是在beta1上的吧?在beta2上是这样的


using System;

namespace ConsoleApplication15
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
string str="12345";
int xyz=12345;
string strTemp;
int iTemp;
strTemp = xyz.ToString();
iTemp = Convert.ToInt32 (str);
Console.WriteLine(strTemp);
Console.WriteLine(iTemp);
}
}
}
chaseismydream 2001-07-30
  • 打赏
  • 举报
回复
Longee():
sorry,一不小心,给错分了,想改也不知道怎样改?只能口头上说声:谢谢了! bicom(想
bicom(想学VC++):
你白捡了!!
bicom 2001-07-30
  • 打赏
  • 举报
回复
楼上的完全正确!!!
Longee 2001-07-29
  • 打赏
  • 举报
回复
:) sorry

string str="12345";
int xyz=12345;
string strTemp;
int iTemp;
strTemp = xyz.ToString();
iTemp = str.ToInt32();
chaseismydream 2001-07-29
  • 打赏
  • 举报
回复
Longee():
string str="12345";
int xyz=12345;
string strTemp;
int iTemp;
strTemp = xyz.ToString(); //可以
iTemp = (int)str; //E Cannot convert type "string" to "int"(cs0030)

Longee 2001-07-28
  • 打赏
  • 举报
回复
直接使用类型转换不就可以了吗?

string str="12345";
int xyz=12345;

string strTemp;
int iTemp;

strTemp = xyz.ToString();
iTemp = (int)str;
chaseismydream 2001-07-28
  • 打赏
  • 举报
回复
bobar(BO) :
有这个convert 吗?我怎么找不到.能否具体一点?
easytimer 2001-07-28
  • 打赏
  • 举报
回复
我也想知道,我是说互相转换,不是单向,分别用什么函数?
以前用C的函数,好烦,有没有C++的,最好是MFC的
bobar 2001-07-28
  • 打赏
  • 举报
回复
convert class 的Tostring

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧