Answers for "get index Brushes properties C#"

C#
0

get index Brushes properties C#

private Brush PickBrush()
{
    Brush result = Brushes.Transparent;

    Random rnd = new Random();

    Type brushesType = typeof(Brushes);

    PropertyInfo[] properties = brushesType.GetProperties();

    int random = rnd.Next(properties.Length);
    result = (Brush)properties[random].GetValue(null, null);

    return result;
}
Posted by: Guest on August-20-2021
0

get index Brushes properties C#

Random rnd = new Random();
Brush brush = brushes[rnd.Next(brushes.Length)];
Posted by: Guest on August-20-2021

C# Answers by Framework

Browse Popular Code Answers by Language