日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

c# 浮点数十六进制字符串_从C#中包含十六进制值的字符串数组中打印整数值...

發(fā)布時間:2025/3/11 C# 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c# 浮点数十六进制字符串_从C#中包含十六进制值的字符串数组中打印整数值... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

c# 浮點數(shù)十六進制字符串

將十六進制字符串數(shù)組轉(zhuǎn)換為整數(shù) (Converting array of hexadecimal strings to integers)

Let suppose you have some of the strings (i.e. array of strings) containing hexadecimal values like "AA", "ABCD", "ff21", "3039", "FAFA" which are equivalent to integers 170, 43981, 65313, 12345, 64250.

假設(shè)您有一些字符串(即字符串數(shù)組)包含十六進制值,例如“ AA”,“ ABCD”,“ ff21”,“ 3039”,“ FAFA” ,它們等效于整數(shù)170、43981、65313、12345, 64250 。

As we have written in the previous post: convert hexadecimal string to integer, we use Convert.ToInt32() function to convert the values.

正如我們在上一篇文章中所寫的: 將十六進制字符串轉(zhuǎn)換為integer ,我們使用Convert.ToInt32()函數(shù)轉(zhuǎn)換值。

We will access each item using a foreach loop, and convert the item to an integer using base value 16.

我們將使用foreach循環(huán)訪問每個項目,并使用基值16將其轉(zhuǎn)換為整數(shù)。

Code:

碼:

using System; using System.Text;namespace Test {class Program{static void Main(string[] args){string[] str = { "AA", "ABCD", "ff21", "3039", "FAFA"};int num = 0;try{//using foreach loop to access each items//and converting to integer numbers foreach (string item in str){num = Convert.ToInt32(item, 16);Console.WriteLine(num);}}catch (Exception ex){Console.WriteLine(ex.ToString());}//hit ENTER to exitConsole.ReadLine();}} }

Output

輸出量

170 43981 65313 12345 64250

翻譯自: https://www.includehelp.com/dot-net/print-integer-values-from-an-array-of-strings-containing-hexadecimal-values-in-c-sharp.aspx

c# 浮點數(shù)十六進制字符串

總結(jié)

以上是生活随笔為你收集整理的c# 浮点数十六进制字符串_从C#中包含十六进制值的字符串数组中打印整数值...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。