# Some Haxe C# implementation questions

**URL:** <https://community.haxe.org/t/some-haxe-c-implementation-questions/1630>\
**Category:** Haxe\
**Tags:** haxe-cs\
**Created:** [March 27, 2019, 8:17pm UTC](https://community.haxe.org/t/some-haxe-c-implementation-questions/1630 "2019-03-27T20:17:13Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![pshtif](https://community.haxe.org/user_avatar/community.haxe.org/pshtif/32/783_2.png) [@pshtif](https://community.haxe.org/u/pshtif)\
**Post date:** [March 27, 2019, 8:17pm UTC](https://community.haxe.org/t/some-haxe-c-implementation-questions/1630/1 "2019-03-27T20:17:13Z")

</div>

Hi guys, it’s been actually quite some time I’ve been around. Nowadays I started to play with hxcs to implement another target for my framework. However before I delve into the research which seems sporadic at least and will probably result in a lot of try and see. I have a few specific questions about using Haxe with C#

1. Asynchronous stuff for example in Unity is quite a common occurrence how would you go on implementing code like this in haxe so it correctly transpiles to Unity C#?

```haxe
    void Start()
    {
        StartCoroutine(GetRequest("https://www.example.com"));
    }

    IEnumerator GetRequest(string uri)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
        {
            yield return webRequest.SendWebRequest();

            string[] pages = uri.Split('/');
            int page = pages.Length - 1;

            if (webRequest.isNetworkError)
            {
                Debug.Log(pages[page] + ": Error: " + webRequest.error);
            }
            else
            {
                Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
            }
        }
    }

```

1. Is there a way to inject a block of C# code into a haxe code? Instead of using multiple untyped calls?

2. What is the best way to call external C# code from within haxe code? Keeping in mind that in most cases I want to get a return value as well.

So if anyone can at least give me a hint it will definitely save me quite some time that I can spend on coding the actual framework and bringing haxe evangelism even further.

Thanks.

---

_[View the full topic](https://community.haxe.org/t/some-haxe-c-implementation-questions/1630)._
