B Property
Collapse the table of content
Expand the table of content

Color.B Property


Gets the blue component value of this Color structure.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public byte B { get; }

Property Value

Type: System.Byte

The blue component value of this Color.

The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). Each of the four components is a number from 0 through 255, with 0 representing no intensity and 255 representing full intensity. Likewise, B is a value from 0 to 255 with 0 representing no blue and 255 representing fully blue.

The following code example demonstrates the A, R, G, and B properties of a Color, and the Implicit(Size to SizeF) member.

This example is designed to be used with a Windows Form. Paste the code into the form and call the ShowPropertiesOfSlateBlue method from the form's Paint event-handling method, passing e as PaintEventArgs.

private void ShowPropertiesOfSlateBlue(PaintEventArgs e)
    Color slateBlue = Color.FromName("SlateBlue");
    byte g = slateBlue.G;
    byte b = slateBlue.B;
    byte r = slateBlue.R;
    byte a = slateBlue.A;
    string text = String.Format("Slate Blue has these ARGB values: Alpha:{0}, " +
        "red:{1}, green: {2}, blue {3}", new object[]{a, r, g, b});
        new Font(this.Font, FontStyle.Italic), 
        new SolidBrush(slateBlue), 
        new RectangleF(new PointF(0.0F, 0.0F), this.Size));

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft