As VS and doc say, it is not a predefined type
It works inside unsafe { } or
with Marshal.SizeOf(typeof(Int128) (or Marshal.SizeOf<Int128>())
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
What are the differences between Int128 and other Int groups such as Int16, Int32, and Int64?
The sizeof operator doesn't work on Int128.
As VS and doc say, it is not a predefined type
It works inside unsafe { } or
with Marshal.SizeOf(typeof(Int128) (or Marshal.SizeOf<Int128>())
Hi @Shervan360 ,
sizeof
operator works with Int16
, Int32
, and Int64
because they are common, well-defined primitive types in C#.Int128
, which is a new type introduced in .NET 7, the sizeof(Int128)
is not allowed directly in safe code. This is because Int128
is not yet widely used or supported in the same way as other primitive types. To use sizeof
with Int128
, it must be in an unsafe context in C#, where pointers are allowed.Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.