unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm1 = class(TForm) btn1: TBitBtn; procedure btn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} procedure TForm1.btn1Click(Sender: TObject); begin form2.ShowModal; end; end.
转换后
Unit2.cs 的代码为
using System; using System.Windows.Forms; using Unit2; namespace Unit1 { public partial class TForm1: Form { public TForm1() { InitializeComponent(); } public void btn1Click(System.Object Sender, System.EventArgs _e1) { Unit2.Units.Unit2.Form2.ShowDialog();//ShowDialog } } // end TForm1 } namespace Unit1.Units { public class Unit1 { public static TForm1 Form1 = null; } // end Unit1 }