using System;
using System.Text.RegularExpressions;
namespace BinaryStringToInteger
{
class Program
{
static void Main(string[] args)
{
BinaryStringToInteger("1000000000000000000");
Console.ReadKey();
}
static readonly Regex Binary = new Regex("^[01]{1,32}$", RegexOptions.Compiled);
static void BinaryStringToInteger(string s)
{
if (Binary.IsMatch(s))
{
Console.WriteLine(Convert.ToInt32(s, 2));
}
else
{
Console.WriteLine("invalid: " + s);
}
}
}
}
2017年1月2日 星期一
C# 二進制字串轉數值
範例:將字串 "1000000000000000000" 轉成 int 數值
訂閱:
張貼留言 (Atom)
Visual Studio 2017/2019 推薦的擴充功能與更新
參考文章: 覺得 Google 的 Blogger 不太順手?透過 HTML 的 iframe 移花接木 HackMD
-
最近電腦沒在操作,CPU 風扇一直高速在運轉,查了一下工作管理員,發現 WMI Provider Host 一直占用著 CPU。 檢查一下「事件檢視器」應用程式及服務紀錄檔\Microsoft\Windows\WMI-Activity\Poerational,發現有錯誤一...
-
當無法修復或解除安裝 Visual Studio 時, 可以透過 InstallCleanup.exe 工具來移除所有安裝的 Visual Studio。 InstallCleanup.exe 工具所在的目錄: C:\Program Files (x86)\Micros...
沒有留言:
張貼留言