我总是记不住电话号码。我需要一个记忆规则。


当前回答

我能想到的最正确的答案是Int32.MaxValue。

其他回答

有趣的是,Int32。MaxValue拥有超过2,147,486,647个字符。

但话说回来,我们有代码完成,

所以我想我们真正需要记住的是Int3<period>M<enter>,这在visual studio中只有6个字符。

更新 出于某种原因,我被否决了。我能想到的唯一原因是他们没有理解我的第一句话。

“Int32。MaxValue最多需要14个字符来输入。 2147,486,647需要输入10或13个字符,这取决于是否使用逗号。

无论如何,取这个正则表达式(它确定字符串是否包含一个十进制形式的非负整数,也不大于Int32.MaxValue)

[0-9] {1, 9} | [0, 1] [0-9] {1, 8} | 20 [0-9] {1, 8} | 21 [0, 3] [0-9] {1, 7} | 214 [0-6] [0-9] {1, 7} | 2147 [0, 3] [0-9] {1, 6} | 21474 [0] [0-9] {1, 5} | 21 4748 [2-0] [0-9] {1, 4} | 2147483 [0 to 5] [0-9] {1, 3} | 21474836 [0, 3] [0-9] {1, 2} | 214748364 [0]

也许能帮你记起来。

我在c#中做了几个天才的方法,你可以在你的生产环境中利用:

public static int GetIntMaxValueGenius1()
{
    int n = 0;
    while (++n > 0) { }
    return --n;
}

public static int GetIntMaxValueGenius2()
{
    int n = 0;
    try
    {
        while (true)
            n = checked(n + 1);
    }
    catch { }
    return n;
}

这就是我如何记住2147483647的:

214 -因为2.14近似于pi-1 48 = 6*8 64 = 8*8

横向写:

214_48_64_
and insert:
   ^  ^  ^
   7  3  7 - which is Boeing's airliner jet (thanks, sgorozco)

现在你得到了2147483647。

希望这能有所帮助。

2GB

(回答有最短长度限制吗?)