using System; using System.Numerics; class Program { static void Main() { float[,] m = new float[,] { { 2, 1 }, { 3, 4 } }; Matrix2x2 mat = new Matrix2x2(m); Matrix2x2 matInv = Matrix2x2.Invert(mat); Console.WriteLine(matInv.ToString()); } }
using System; using System.Numerics; class Program { static void Main() { float[,] m = new float[,] { { 1, 2, 1 }, { 0, 1, 0 }, { 0, 0, 1 } }; Matrix3x3 mat = new Matrix3x3(m); Matrix3x3 matInv = Matrix3x3.Invert(mat); Console.WriteLine(matInv.ToString()); } }This code creates a 3x3 matrix and then calculates its inverse using the `Matrix3x3.Invert()` method. The resulting inverse matrix is printed to the console. The System Matrix Inverse is part of the System.Numerics namespace in C#, which is included in the .NET Framework Class Library.