# Mixed Oxygene and C# code, implicit operator cannot be matched

**URL:** https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433
**Category:** Elements
**Tags:** island, visual-studio
**Created:** [February 21, 2020, 10:50pm UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433 "2020-02-21T22:50:11Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![wuping](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/w/5f8ce5/32.png) [@wuping](https://talk.remobjects.com/u/wuping)
#### Post date: [February 21, 2020, 10:50pm UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/1 "2020-02-21T22:50:11Z")

</div>

Elements **2485** , Island/Windows @ck @mh

I have a project that mixes C# and Oxygene sources. It seems to me, the **C#** code cannot be matched to Oxygene’s **implicit operator** , for example,

The C# code **Graph.Const** ( **{1,2}** ), should be matched to Oxygene’s **Graph.Const** ( **aTensor: Tensor** ), because Tensor has an implicit operator: **operator implicit (array of Integer): Tensor**

But it seems to me - t **he implicit operator cannot be matched as expected.**

 ![2020-02-21_17-38-16](https://talk.remobjects.com/uploads/default/original/2X/2/243e6772d5235bed5ce0d2c9ab3fcd103924bf30.jpeg)

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [February 21, 2020, 10:56pm UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/2 "2020-02-21T22:56:21Z")

</div>

There must me more to this than just the language diff. Can we get a small test case?

---

<div class="post-metadata">

### Author: ![wuping](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/w/5f8ce5/32.png) [@wuping](https://talk.remobjects.com/u/wuping)
#### Post date: [February 21, 2020, 11:25pm UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/3 "2020-02-21T23:25:26Z")

</div>

> [@mh](#):
>
> Can we get a small test case?

Yes - I cleaned up and get this new Test case:  
[https://www.sugarsync.com/pf/D6147121\_09656321\_171158](https://www.sugarsync.com/pf/D6147121_09656321_171158)

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [February 22, 2020, 6:17am UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/4 "2020-02-22T06:17:34Z")

</div>

shouldn’t that be new[]{1,2} ? Plain {1,2} isn’t valid as an array.

---

<div class="post-metadata">

### Author: ![wuping](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/w/5f8ce5/32.png) [@wuping](https://talk.remobjects.com/u/wuping)
#### Post date: [February 22, 2020, 8:52am UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/5 "2020-02-22T08:52:37Z")

</div>

No. The issue seems to be **a problem with mixed code**.

A **pure C# project** , would not have this problem - the compiler will **automatically/conveniently generate a temporary** new []{1,2,3} for the array literal {1,2,3}.

For example, the following **code runs not problem in a pure-bred C# project** (Island/Windows):

```
class Test
{
    public static implicit operator Test(int[] arr)
    {
        Console.WriteLine("matched~");
    }        
}

static class Program
{
    public static Int32 Main(string[] args)
    {
        Console.WriteLine("The magic happens here.");
        DoSomething({1,2,3}); // This is a array literal that compiler takes care of
        Console.ReadLine();
        return 0;
    }
    
    public static void DoSomething(Test test)
    {

    }
}

```

@ck

---

<div class="post-metadata">

### Author: ![wuping](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/w/5f8ce5/32.png) [@wuping](https://talk.remobjects.com/u/wuping)
#### Post date: [February 22, 2020, 3:50pm UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/6 "2020-02-22T15:50:27Z")

</div>

@ck, @mh, some additional information for your insights:

if I put _ **the mixed code into a .fx file** _, the compiler will just pass.

In other words:

For the **.fx** , it has:

- Oxygene source
- C# source

For the **main executable** :

- C#, passing a array literal to a method defined in .fx, the compiler does **NOT** generate any warnings or errors, and the executable just runs fine.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [February 23, 2020, 11:13am UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/7 "2020-02-23T11:13:29Z")

</div>

Thanks, logged as [bugs://83979](https://www.remobjects.com/portal/bugs/?id=83979)

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [February 23, 2020, 11:17am UTC](https://talk.remobjects.com/t/mixed-oxygene-and-c-code-implicit-operator-cannot-be-matched/21433/8 "2020-02-23T11:17:22Z")

</div>

[bugs://83979](https://www.remobjects.com/portal/bugs/?id=83979) got closed with status fixed.
