• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

rogeralsing/ProjectExodus: Transpiler from C# to Kotlin.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

rogeralsing/ProjectExodus

开源软件地址(OpenSource Url):

https://github.com/rogeralsing/ProjectExodus

开源编程语言(OpenSource Language):

C# 100.0%

开源软件介绍(OpenSource Introduction):

ProjectExodus

Transpiler from C# to Kotlin.

Very early pre alpha

Demo:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Example
    {
        public void Main()
        {
            var i = 1.ToString();
            var res = Console.ReadLine();
            Console.WriteLine("You wrote " + res);
        }

        public void Conditionals()
        {
            var x = 1 > 2 ? "a" : "b";
        }
        public string Arrays(string[] strings)
        {
            if (strings == null)
            {
                return "null";
            }
            var x = "";
            foreach (var s in strings)
            {
                x += "," + s;
            }
            return x;
        }

        public void Linq()
        {
            int[] ints = {1, 2, 3, 4, 5, 6, 7, 8};
            var big = ints.Where(i => i > 4).Select(i => i*2).ToList();
        }

        public void Delegates()
        {
            Action<int, string> del = (a, b) =>
            {
                Console.WriteLine("{0} {1}", a, b);
            };
            Func<int, string> del2 = a => "hello" + a;
            InvokeIt(del);
        }

        private void InvokeIt(Action<int, string> del)
        {
            del(1, "hello");
        }
    }
}

Gets transpiled into

package consoleapplication3

class Example {
    fun main () : Unit {
        var i : String = 1.toString()
        var res : String = readLine()
        println("You wrote " + res)
    }
    fun conditionals () : Unit {
        var x : String = if (1 > 2) "a" else "b"
    }
    fun arrays (strings : Array<String>) : String {
        if (strings == null) {
            return "null"
        }
        var x : String = ""
        for(s in strings) {
            x += "," + s
        }
        return x
    }
    fun linq () : Unit {
        var ints : Array<Int> = arrayOf(1, 2, 3, 4, 5, 6, 7, 8)
        var big : List<Int> = ints.filter{it > 4}.map{it * 2}.toList()
    }
    fun delegates () : Unit {
        var del : (Int, String) -> Unit = {a, b ->
            println("{0} {1}", a, b)
        }

        var del2 : (Int) -> String = {a -> "hello" + a}
        invokeIt(del)
    }
    fun invokeIt (del : (Int, String) -> Unit) : Unit {
        del(1, "hello")
    }
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap