Pergunta

Hello I'm using the Microsoft.VisualBasic.PowerPacks Name space to create shapes on a windows form. I've used an array to store all the objects so that i can generate new shapes and modify the properties of a collection of objects, dependent on given scenarios.

I'm attempting to perform a look-up on the array an find the lowest index that contains an Oval Shape. After trawling the internet for quite some time, I've only found statements that will accept fixed values, since every location within the array contains the same value I can't do that.

I'm looking for something along the lines of the statement below. Where i can find either the first entry that is not null or contains an "Microsoft.VisualBasic.Powerpacks.Ovalshape" the object not the type. Thanks.

// ** Object declaration
Microsoft.VisualBasic.PowerPacks.OvalShape shape = new Microsoft.VisualBasic.PowerPacks.OvalShape();    
Microsoft.VisualBasic.PowerPacks.OvalShape[] shapes;
**//


     int myIndex = Array.IndexOf(shapes, != null);
Foi útil?

Solução

Simply use:

Array.FindIndex(shapes, s => s != null)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top