Skip to content

Неудача - #19

Open
Palezehvat wants to merge 1 commit into
mainfrom
OffsetFirstTry
Open

Palezehvat wants to merge 1 commit into
mainfrom
OffsetFirstTry

Conversation

@Palezehvat

Copy link
Copy Markdown
Owner

No description provided.

@@ -0,0 +1,93 @@
using System;

namespace NewFindACouple

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо использовать file-scoped namespaces, namespace NewFindACouple; и дальше без фигурной скобки и отступа

{
if (button.Tag == null || previousButton.Tag == null)
{
throw new NullReferenceException();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NullReferenceException в принципе кидать нельзя, оно системное :)

public void AddGrid(int size)
{

int[] arrayForNumbers = new int[size * size];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int[] arrayForNumbers = new int[size * size];
var arrayForNumbers = new int[size * size];


for (int i = 0; i < size; i++)
{
var random = new Random();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Никогда не создавайте Random в цикле, а то он почти всегда одни значения возвращать будет. Ну и сборщик мусора спасибо не скажет

{
for (int j = 0; j < size; ++j)
{
Button button = new Button();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Button button = new Button();
Button button = new();

@@ -0,0 +1,2 @@
namespace NewFindACouple;
internal class IncorectNumberException : Exception{} No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
internal class IncorectNumberException : Exception{}
internal class IncorrectNumberException : Exception{}

Comment on lines +11 to +12
int result = 0;
bool check = int.TryParse(args[0], out result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int result = 0;
bool check = int.TryParse(args[0], out result);
bool check = int.TryParse(args[0], out int result);

this.Controls.Add(button);
top += button.Height + 2;
button.Name = "btn" + i + '.' + j;
button.Tag = arrayForNumbers[k].ToString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Непонятно, как обеспечивается "парность" кнопок, в массиве ведь просто числа от 0 до size * size

button.Tag = "-";
}
}
previousButtonTag = string.Copy(button.Tag.ToString());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string.Copy не нужен, просто присвоения достаточно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants