Font font = new Font("Arial", 12); float height = font.GetHeight(); Console.WriteLine("Font height in pixels: " + height);
ListIn this example, we create a list of font names. Then we iterate through each font and create a new `Font` object with size 10 and store its height in a float variable using `GetHeight()` method. Finally, we display the font name and its height in pixels on console. Both examples given above use `System.Drawing` namespace in C#.fontNames = new List () { "Arial", "Calibri", "Times New Roman" }; foreach (string fontName in fontNames) { Font font = new Font(fontName, 10); float height = font.GetHeight(); Console.WriteLine("Font height of " + fontName + " in pixels: " + height); }