在C#中添加六值 [英] Adding hexa values in C#

查看:118
本文介绍了在C#中添加六值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的系统,我需要添加2六角形values.So,我怎么能在C#中添加六价值观?我也想知道十六进制值的最大长度和实例持有这些值。

In my system,i need to add 2 Hexa values.So, how can i add hexa values in C#? And i also want to know the max length of Hexa values and which Instance hold these values.

推荐答案

有关64个字符的数字,你需要使用 的BigInteger 类型的.Net 4,正常的类型太小:

For 64 character numbers, you need to use the BigInteger type of .Net 4, the normal types are too small:

BigInteger bi1 = BigInteger.Parse("123456789012345678901234567890123456789012345678901234567890abc5", NumberStyles.HexNumber);
BigInteger bi2 = BigInteger.Parse("123456789012345678901234567890123456789012345678901234567890abc1", NumberStyles.HexNumber);
BigInteger sum = BigInteger.Add(bi1, bi2);
Console.WriteLine("{0:x}", sum); //or sum.ToString("x")



(记得加入<$ C $参考C> System.Numerics )

这篇关于在C#中添加六值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆