Import from CSharp
From The Oxygene Language Wiki
This is an IDE topic
Feel free to add your notes to this topic below.
(TODO: merge into Oxidizer)
Portions of existing C# code can easily be converted into the equivalent Delphi Prism code using the Import C# menu item available in the context menu for the Delphi Prism project in the Solution Explorer.
This feature is very similar to Paste CSharp as Oxygene, but it allows to import one or more C# source files at once, while the latter only handles a single source file.
For example, the following C# source file
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Thread lTestThread = new Thread(delegate() { Int32 i = 0; while (i < 4) { Console.WriteLine("Thread Step " + i.ToString()); i++; } }); lTestThread.Start(); Console.ReadLine(); } } }
will be imported as
namespace ConsoleApplication1; interface uses System, System.Collections.Generic, System.Linq, System.Text, System.Threading; type Program = class private class method Main(args: array of System.String); end; implementation class method Program.Main(args: array of System.String); begin var lTestThread: Thread := new Thread(method begin var i: Int32 := 0; while i < 4 do begin Console.WriteLine('Thread Step ' + i.ToString()); {POST}inc(i) end end); lTestThread.Start(); Console.ReadLine() end; end.
See Also
Area: Oxygene IDE
IDE Glossary — Keywords — Types — FAQ — How To