在类结构方面,是否有一个官方的c#项目顺序指南?

它是这样的:

公共字段 私有字段 属性 构造函数 方法 ?

我很好奇物品的摆放顺序是否有硬性规定?我有点到处都是。我想坚持一个特定的标准,这样我就可以在任何地方使用它。

真正的问题是我的更复杂的属性最终看起来很像方法,它们在构造函数之前的顶部感觉不合适。

任何建议/建议吗?

对于一个挑战,一位代码高尔夫球手编写了以下代码:

import java.util.*;
public class Main {
  public static void main(String[] args) {
    int size = 3;
    String[] array = new String[size];
    Arrays.fill(array, "");
    for (int i = 0; i <= 100;) {
      array[i++ % size] += i + " ";
    }
    for (String element: array) {
      System.out.println(element);
    }
  }
}

当在Java 8中运行这段代码时,我们得到以下结果:

1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97 100 
2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 53 56 59 62 65 68 71 74 77 80 83 86 89 92 95 98 101 
3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 

当在Java 10中运行这段代码时,我们得到以下结果:

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 

在Java 10中,这种编号完全不存在。这里发生了什么?这是Java 10中的bug吗?

评论跟进:

The issue appears when compiled with Java 9 or later (we found it in Java 10). Compiling this code on Java 8, then running in Java 9 or any later version, including Java 11 early access, gives the expected result. This kind of code is non-standard, but is valid according to the spec. It was found by Kevin Cruijssen in a discussion in a golfing challenge, hence the weird use case encountered. Didier L simplified the issue with this much smaller and more understandable code: class Main { public static void main(String[] args) { String[] array = { "" }; array[test()] += "a"; } static int test() { System.out.println("evaluated"); return 0; } } Result when compiled in Java 8: evaluated Result when compiled in Java 9 and 10: evaluated evaluated The issue seems to be limited to the string concatenation and assignment operator (+=) with an expression with side effect(s) as the left operand, like in array[test()]+="a", array[ix++]+="a", test()[index]+="a", or test().field+="a". To enable string concatenation, at least one of the sides must have type String. Trying to reproduce this on other types or constructs failed.

I keep seeing "bootstrapping" mentioned in discussions of application development. It seems both widespread and important, but I've yet to come across even a poor explanation of what bootstrapping actually is; rather, it seems as though everyone is just supposed to know what it means. I don't, though. Near as I can figure, it has something to do with initialization tasks required of an application upon launch, but I could be completely wrong about that. Can anyone help me to understand this idea?

我和c中的size_t搞混了,我知道它是由sizeof操作符返回的。但它究竟是什么?它是数据类型吗?

假设我有一个for循环:

for(i = 0; i < some_size; i++)

我应该用int I吗?或者size_t i;?

点(.)和美元符号($)的区别是什么?

根据我的理解,它们都是不需要使用括号的语法糖。

我听说了很多关于PyPy项目的事情。他们声称它比他们网站上的CPython解释器快6.3倍。

每当我们谈论像Python这样的动态语言时,速度是首要问题之一。为了解决这个问题,他们说PyPy要快6.3倍。

第二个问题是并行性,即臭名昭著的全局解释器锁(GIL)。为此,PyPy说它可以提供无gil的Python。

如果PyPy可以解决这些巨大的挑战,那么它的弱点是什么?也就是说,是什么阻止了像我这样的典型的Python开发人员现在转向PyPy ?

我听说static_cast函数应该优于c风格或简单函数风格的强制转换。这是真的吗?为什么?

有办法做到这一点吗?

还是我必须手动从登记处取每一条记录?

我正在尝试在我的Windows 7 x64系统上安装Android SDK。

安装了JDK -6u23-windows-x64.exe,但Android SDK安装程序拒绝继续,因为它没有找到JDK安装。

这是已知的问题吗?有解决办法吗?

一个 URL、一个 URI 和一个 URN 的区别是什么?