C# 轉Delphi.NET程式碼工具(含程式碼) |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
參考資料:
http://dotnet.borland.com/babelcode/
http://bdn.borland.com/article/0,1410,32338,00.html
Delphi 2005範例下載: (Using the Borland WebService BabelCode)
http://www.dpexperte.de/articles/d3k/d2005_babelcode/BabelCodeClient.zip 本文是C#寫法... 網海無涯,唯學是岸! 發表人 - qoo1234 於 2005/08/20 09:11:43
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
Delphi 7 範例:匯入wsdl檔後,產生..converter.pas檔
操作converter單元程式碼如下:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,converter, StdCtrls, ComCtrls, InvokeRegistry, Rio, SOAPHTTPClient; type TForm1 = class(TForm) RichEdit1: TRichEdit; //放C#程式碼 Button1: TButton; RichEdit2: TRichEdit; //Delphi.NET程式碼轉換結果 HTTPRIO1: THTTPRIO; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin RichEdit2.Text:=(HTTPRIO1 as BabelCodeSoap).CSharpToDelphi(RichEdit1.Text); end; end.網海無涯,唯學是岸! 發表人 - qoo1234 於 2005/08/20 23:00:41 |
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
測試後的結論: C#轉譯Delphi.NET還有一段路要走, 但目前也可以當作人工翻譯參考。 1.正常Delphi.NET程式碼: program Project1; {$APPTYPE CONSOLE} var strArray : System.Array; index : Integer; begin // Create a 5 element single dimension array of Strings strArray := System.Array.CreateInstance(TypeOf(String), 5); // Fill out the array in sorted sequence // (We could have used the static 'Sort' method to do the sort strArray.SetValue('ABC', 0); strArray.SetValue('DEF', 1); strArray.SetValue('GHI', 2); strArray.SetValue('JKL', 3); strArray.SetValue('MNO', 4); // Try to find 'GHI' index := System.Array.BinarySearch(strArray, 'GHI'); Console.WriteLine('The index of ''GHI'' is {0}', index.ToString); // Try to find 'GHZ' index := System.Array.BinarySearch(strArray, 'GHZ'); Console.WriteLine('The index of ''GHZ'' is {0}', index.ToString); // Try to find 'ZZZ' index := System.Array.BinarySearch(strArray, 'ZZZ'); Console.WriteLine('The index of ''ZZZ'' is {0}', index.ToString); Console.ReadLine; end. 2.人工翻譯為C#程式碼結果: using System; namespace myConsole { class MainClass { public static void Main(string[] args) { string[] strArray = new string[5]; strArray.SetValue("ABC", 0); strArray.SetValue("DEF", 1); strArray.SetValue("GHI", 2); strArray.SetValue("JKL", 3); strArray.SetValue("MNO", 4); int index= System.Array.BinarySearch(strArray, "GHI"); Console.WriteLine("The index of 'GHI' is {0}", index.ToString()); index = System.Array.BinarySearch(strArray, "GHZ"); Console.WriteLine("The index of 'GHZ' is {0}", index.ToString()); index = System.Array.BinarySearch(strArray, "ZZZ"); Console.WriteLine("The index of 'ZZZ' is {0}", index.ToString()); Console.ReadLine(); } } } 3.本軟體透過線上轉譯Delphi.NET程式碼結果: //------------------------------------------------------------------------------ //網海無涯,唯學是岸! |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |