Что ж, время ожидания в 2.4 или 2.6 одинаково. Если вы откроете файл urllib2.py в 2.6, вы увидите, что он принимает дополнительный аргумент в качестве тайм-аута и обрабатывает его с помощью метода socket.defaulttimeout (), как упоминалось в ответе 1.
Так что вам действительно не нужно обновлять ваш urllib2.py в этом случае.
The first bullet point is correct.
The second is not: the primitive types in .NET are Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, and Single. A struct cannot usually be set to null
, but there are also nullable value types (Nullable
). These are still value types, but there's syntactic sugar in C# to equate "null" with "the null value for the type", which for a nullable value type is an instance where HasValue
returns false.
int
and System.Int32
are exact synonyms in C#. The former is just an alias for the latter. They compile to exactly the same code.
In C#, classes and interfaces are always reference types. Structs and enums are value types - but there is a boxed equivalent of every struct (other than Nullable
which is handled differently by the CLR in terms of boxing). The boxed types don't have separate names, and can't be referred to explicitly in C# (although they can be in C++/CLI). There is no separate wrapper class equivalent like java.lang.Integer
in .NET; it would be problematic to introduce such classes as you can create your own value types in .NET, unlike in Java.
For more information on reference types and value types, see my article about it.
I haven't seen MS docs to be contradictory about this (MSDN is sometimes wrong, but on this specific issue, I've always seen it correct). The MSDN link you posted says:
For each primitive data type in Java, the core class library provides a wrapper class that represents it as a Java object. For example, the Int32 class wraps the int data type, and the Double class wraps the double data type.
On the other hand, all primitive data types in C# are objects in the System namespace. For each data type, a short name, or alias, is provided. For instance, int is the short name for System.Int32 and double is the short form of System.Double.
Basically, it's saying the right thing. In Java, Integer
class is a wrapper for int
primitive type. In C#, int
is an alias for System.Int32
structure. The first paragraph is about Java and doesn't apply to C#.
In .NET, the terminology is as follows:
A primitive type is a type that has IsPrimitive
property set to true. Primitive types are:
The primitive types are Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double и Single.
Все примитивные типы являются типами значений, но не наоборот .
Тип значения - это тип , который имеет семантику значения, в отличие от к семантике ссылок . Все значение копируется при передаче по значению (а не по ссылке). Локальные переменные типов значений хранятся в стеке. struct
s и enum
s являются типами значений.
Как упоминалось выше, все примитивные типы являются типами значений. Это структуры struct
в пространстве имен System
. В C #, int
, double
и т. Д. Ключевые слова в основном являются псевдонимами для тех struct
s.