基本的に、オブジェクト指向プログラミングの紹介として、WriteLine の内容を WinForm の Label ボックスに移動しようとしています。構文エラーがあると思いますが、書き込み行があるメソッドが無効であることはわかっています。したがって、これを機能させるための助けをいただければ幸いです。これは私が行った試みの 1 つにすぎません。
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;
using ConsoleHelloWorld.Program;
namespace WindowsFormHelloWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string words = new ConsoleHelloWorld.Program.Main(words);
label1.Text = words;
}
}
}
これは私が参照しているコードです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleHelloWorld
{
public static class Program
{
public static void Main(string[] args)
{
string words = "hello world";
Console.WriteLine(words);
Console.ReadLine();
}
}
}