Click here to Skip to main content
15,889,877 members

Comments by Arthur Dragon (Top 12 by date)

Arthur Dragon 25-Dec-22 12:36pm View    
Deleted
It still does not work:(. All it does now is just highlight a random square red (one I do not click on after clicking) I do not know how to solve this
Arthur Dragon 22-Dec-22 18:45pm View    
Deleted
When I put the cast int value = (int)(((Button)gridEnemy.Children[x]).Tag); it gives out an error point to that line of a null reference exception. I thought the int value is now assigned with a value so the task of assigning it something is done so I don't under how it throws a nullreference.
Arthur Dragon 22-Dec-22 15:09pm View    
It is getting closer but it still does not work. When I do statement inside the for loop (((Button)gridEnemy.Children[x].Tag == 1 the expression gets underlined in red giving out an error that the operator == cannot be applied to operands of type 'object' and 'int'.
Arthur Dragon 22-Dec-22 8:25am View    
I tried putting them all into an Array but it didn't work out so I am using the arrays. This is what I have and it is giving me an error saying x does not exist in the current context. I know that it does not exist but how do I pass the meaning of the x's that were in the assigned to each button in the for loops of the random ship function



enemyShips.RandomShip(gridEnemy);

if (((Button)gridEnemy.Children[x]).Tag == 1)
{
((Button)gridEnemy.Children[enemyShips.x]).Background = Brushes.Red;
}
else
{
((Button)sender).Background = Brushes.Blue;
}
Arthur Dragon 22-Dec-22 6:50am View    
how do I reach out to the tags that I assigned to the x's in the randomShip() function