Measure String Size In Pixels (C#) Graphics.MeasureString Method: Graphics graphics = this.CreateGraphics(); SizeF textSize = graphics.MeasureString("How long am I?", this.Font); TextRenderer::MeasureText Method: Size textSize = TextRenderer.MeasureText("How long am I?", font); 原文: Measure String Size In Pixels (C#) Converting integer to hex string (C#) int a = 123; a.ToString("X8"); for 8 hex characters 原本: Converting integer to hex string