Aplikacja Windows Forms
W program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testMatrix
{
static class Program
{
/// <summary>
/// Główny punkt wejścia dla aplikacji.
/// </summary>
[STAThread]
static void Main()
{
Console.Write("Wprowadz rozmiar macierzy: " + Environment.NewLine);
string roz = Matrix.drawMatrix(Convert.ToInt32(Console.ReadLine()));
Application.Run(new ShowMatrix(roz));
}
}
public static class Matrix
{
public static string drawMatrix(int n)
{
string result = string.Empty;
for (int i = 0; i <= n; i++)
{
for (int j = 0; j <= n; j++)
{
if (i == j)
{
result += 1;
}
else
{
result += 0;
}
}
result += Environment.NewLine;
}
return result;
}
}
}
W Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testMatrix
{
public partial class ShowMatrix : Form
{
public ShowMatrix(string result)
{
InitializeComponent();
label1.Text = result;
}
void Button1Click(object sender, EventArgs e)
{
this.Close();
}
}
}
I jeszcze przestawiłem właściwości projektu z Typ wyjściowy: Aplikacja systemu windows na Aplikacja konsolowa.
