Program.cs
で宣言された変数を使用して、その値にForm1.cs
からアクセスする方法を教えてください。C#でのファイルからファイルへの変数の受け渡し
私はCでこれを行う方法を知っているが、私は完全にC.
Program.csの上のMicrosoftの少しひねりで失われています:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using LuaInterface;
namespace WindowsFormsApplication1
{
static class Program
{
public static Lua lua = null;
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
lua = new Lua();
}
}
}
の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.Windows.Forms;
using LuaInterface;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
lua.DoString("print('hi')");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
}
}
C#は "Cのねじれ"ではありません。そして、私はあなたが2つのクラスの間でパラメータを渡すことを意味すると思いますか?または2つのプログラムの間? – Oded
複数のアプローチがあります。コードの一部を投稿してください。 –
私は、あなたが見ることができるように、C#については何を話しているのか正確には分かりません。 2つのクラスが2つの別々のファイルにあるとすれば、それは私が言っていることだと思います。 –