я определил массив и функция, но у меня возникают проблемы с вызовом функции, я должен вызвать функцию, используя имя класса или объектКак вызывать статические методы в классе
public static string PrintArray (int [,] arr)
{
string output = "";
for (int i = 0; i<arr.GetLength(0);i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
output += arr[i,j];
output = output.Substring(0, output.Length)+"/n";
}
return output;
}
public static void Fill(int[,] arr,int min, int max)
{
Random r = new Random();
for (int i = 0; i < arr.GetLength(0); i++)
{
arr[i] = r.Next(min, max);
for (int j = 0; j < arr.GetLength(1); j++)
{
arr[i,j] = r.Next(min, max);
}
}
}
Это 'static' методы, поэтому из класса лучше. – Enigmativity
Комментарий, который не имеет отношения к вашему вопросу: вы можете сократить этот код 'output = output.Substring (0, output.Length) +"/n ";' в 'output = ouput +"/n ";', even более короткий 'output + ="/n ";' – kurakura88