stroke is used like variable

2877 views c#
4

I have a list of rectangles.

   public List<Rectangle> GateBox = new List<Rectangle>();

I want to add a new rectangle to the list like this:

 GateBox.Add(Width = 102, Height = 75, Fill = 
 Application.Current.Resources[file1] as System.Windows.Media.Brush, Stroke = 
 Brushes.Black , Tag = tagnum );

but get an error at

Stroke = Brushes.Black

error is

CS0118 'stroke' is a type but is used like a variable'

Thanks for any suggestions and answers. I'm probably making a stupid mistake.

answered question

I want to add a new rectangle to the list like this: are you sure that's how you do that? IIRC you should pass it a rectangle.

GateBox.Add(new Rectangle{Width = 102, [etc..]})

1 Answer

6

GateBox.Add() expects a Rectangle as argument, but your syntax is wrong and you don't create a Rectangle. Change your code to:

GateBox.Add(new Rectacngle {
     Width = 102, Height = 75, 
     Fill = Application.Current.Resources[file1] as System.Windows.Media.Brush,
     Stroke = Brushes.Black,
     Tag = tagnum});

posted this

Have an answer?

JD

Please login first before posting an answer.