字符串長度計算

字符串長度計算:

            Graphics g = Graphics.FromImage(Image.FromFile("d:\\forcal.png"));
            Size size = g.MeasureString("jinghe zhang", new Font(new FontFamily("Times New Roman"), 12, FontStyle.Regular)).ToSize();
            //g.MeasureString(string str,Font font);
            int stringWidth = size.Width;
            int stringHeight = size.Height;
            Console.WriteLine(stringWidth);
            Console.WriteLine(stringHeight);
            Console.Read();


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章