In which data type can I store a 128-bit data in c#?
For example
dataType bit128 = 340282366920938463463374607431768211455;
What will be the datatype?
If you have .NET Core 7.0 Preview 5 or newer than you can simply use System.Int128
or System.UInt128
They were implemented in Add support for Int128 and UInt128 data types
For some reason .NET 7 Preview 5 announcement didn't include those types, but in the upcoming .NET 7 Preview 6 announcement there'll also be Int128Converter
and UInt128Converter
for the new types in Preview 5
They didn't have C# support yet though, just like System.Half
, so you'll have to use Int128
explicitly instead of using a native C# keyword
You should consider using BigInteger
https://learn.microsoft.com/en-us/dotnet/api/system.numerics.biginteger?redirectedfrom=MSDN&view=net-6.0