Determines if two colors equal. - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Determines if two colors equal.

Demo Code


using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using System.Drawing;
using System.Collections.Generic;
using System;//www  .  j av a2s .  c o  m

public class Main{
        /// <summary>
        /// Determines if two colors equal.
        /// </summary>
        /// <param name="col1">The color to compare.</param>
        /// <param name="col2">The color to compare against.</param>
        /// <returns>True if they field-wise match.</returns>
        public static bool ColorsEqual(Color col1, Color col2) =>
            (col1.A == col2.A && col1.R == col2.R && col1.G == col2.G && col1.B == col2.B);
}

Related Tutorials