General type pointer

Why is the use of pointers in generic types invalid in C #? int?*invalid, while typeof(int?).MakePointerType()not throwing an exception.

According to MSDN, a pointer may contain:

sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal or bool.

Any type of listing.

Any type of pointer.

Any custom structure type that contains only fields of unmanaged types.

I do not see any restrictions regarding generics. int?looks valid since it contains only the booland field int.

+4
source share
1 answer

To specify the C # 5.0 specification §18.2 Pointer types

( ) - , . , struct, , .

- , . , unmanaged-type :

  • sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal bool.
  • .
  • .
  • , .

, , - constructed type.

§ 1.6.3. ( )

, Pair<int,string> , .

, , , . Nullable<int> .

+7

All Articles