将字符串转换为int,而不会在开始处丢失零 [英] Converting string to int without losing the zero in the beginning

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

问题描述

我尝试了 int.parse,并将类转换为int。

I tried int.parse, and convert class to convert a string to int.

m转换。我在开始时输了0,我不想要。

While I'm converting. I'm losing the 0 in the beginning which i don't want.

例如:09999变成了9999 - 我不想要这个。

Ex : 09999 becomes 9999 - I don't want this.

我想保持原样。

我该怎么做?

How can i do that?

推荐答案

你不能。一个 int 是为了表示一个数学整数。数字 09999 9999 在数学上完全相同。

You cannot. An int is meant to represent a mathematical integer. The numbers 09999 and 9999 are exactly the same number, mathematically.

也许这里有一个不同的问题。你为什么需要这样做?也许有更好的方法来做你想做的事情。

Perhaps there is a different problem here. Why do you need to do this? Maybe there's a better way to do what you want to do.

这篇关于将字符串转换为int,而不会在开始处丢失零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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