Ошибка 1 Невозможно применить индексирование через [] к выражению типа "ConsoleApplication1 - C#
Формулировка задачи:
Класс Classm
Класс Program
Застрял на ошибке...
Вот задание:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Classm
{
double[,] m;
public Classm(double[,] m0)
{
m = new double[m0.GetLength(0),m0.GetLength(1)];
m = m0;
}
public static double[,] sumto(ConsoleApplication1.Classm m1, ConsoleApplication1.Classm m2)
{
double[,] s = new double[3, 3];
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
s[i, j] = 0;
for (int k = 0; k < 3; ++k)
{
s[i, j] += m1[i, k] * m2[j, k]; // Ругается тут
}
}
}
return s;
}
}
}using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Classm a = new Classm(new double[,] { { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 } });
Classm b = new Classm(new double[,] { { 10, 10, 10 }, { 20, 20, 20 }, { 30, 30, 30 } });
Classm.sumto(a, b);
Console.ReadKey();
}
}
}
Подсобите плиз... Нужно использовать только те поля, какие есть в задании
Решение задачи: «Ошибка 1 Невозможно применить индексирование через [] к выражению типа "ConsoleApplication1»
textual
Листинг программы
static void Main(string[] args)
{
Classm a = new Classm(new double[,] { { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 } });
Classm b = new Classm(new double[,] { { 10, 10, 10 }, { 20, 20, 20 }, { 30, 30, 30 } });
double[,] c = Classm.sumto(a, b);
for (int i = 0; i < c.GetLength(0); i++)
{
for (int j = 0; j < c.GetLength(1); j++)
Console.Write("{0,6:f1}", c[i, j]);
Console.WriteLine();
}
Console.ReadKey();
}