# How to do Linq in silver?

**URL:** https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629
**Category:** Silver
**Created:** [February 6, 2019, 2:54am UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629 "2019-02-06T02:54:56Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [February 6, 2019, 2:54am UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/1 "2019-02-06T02:54:56Z")

</div>

Hello,

I have the following C# code and want to convert to Swift:

```
public static string Dosomething(string input)

    {

        string output = new string(input.Where(c => !char.IsControl(c)).ToArray());
        return output;

    }

```

Using the convert function:

public static func Dosomething(\_ input: String!) -\> String! {  
var output: String! = String(input.Where({ © in  
!AnsiChar.IsControl©  
}).ToArray())  
return output  
}

The compiler says:

No member “Where” on type "String!  
No static member “IsControl” on type “AnsiChar”

So what is the correct way to do it in silver?

Also, is it possible to do linq using Remobject RTL so that have better code-reused?

Thank you.

---

<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 6, 2019, 5:48am UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/2 "2019-02-06T05:48:19Z")

</div>

Which platform is this? Depending on the platform you have to import the right linq namespace and then it ought to work.

---

<div class="post-metadata">

### Author: ![xiaoguang](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@xiaoguang](https://talk.remobjects.com/u/xiaoguang)
#### Post date: [February 6, 2019, 6:08am UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/3 "2019-02-06T06:08:23Z")

</div>

I am using the .net platform and the linq namespace is already imported:

 ![%E5%9B%BE%E7%89%87](https://talk.remobjects.com/uploads/default/original/2X/8/807c6e09ba1ad22d6880ee621523c22f19cd82ff.png)

---

<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 6, 2019, 12:06pm UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/4 "2019-02-06T12:06:07Z")

</div>

```auto
import System.Collections.Generic
import System.Linq
import System.Text
import System.Threading.Tasks

print("The magic happens here.")

public static func DoSomething(_ input: String!) -> String! {
    var output: String! = String(input.Where {c in !Char.IsControl(c) }.ToArray())
    return output
}

```

this works fine. What am I missing?

---

<div class="post-metadata">

### Author: ![joseasl](https://talk.remobjects.com/user_avatar/talk.remobjects.com/joseasl/32/8050_2.png) [@joseasl](https://talk.remobjects.com/u/joseasl)
#### Post date: [February 6, 2019, 12:24pm UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/5 "2019-02-06T12:24:44Z")

</div>

Looks like there is some conflict with RemObjects.Elements.RTL  
If you create a console application in VS, it doesn’t adds RemObjects.Elements.RTL to the default uses clause. Water adds it. You can try to add import RemObjects.Elements.RTL and it will fail.

---

<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 6, 2019, 12:40pm UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/6 "2019-02-06T12:40:41Z")

</div>

Looks like RTL2 String isn’t a sequence right now. will fix. Meanwhile, workaround is to cast to System.String, if needed. thanx!

---

<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 6, 2019, 12:40pm UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/7 "2019-02-06T12:40:47Z")

</div>

Thanks, logged as bugs://81903

---

<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: [June 12, 2021, 1:59pm UTC](https://talk.remobjects.com/t/how-to-do-linq-in-silver/18629/8 "2021-06-12T13:59:19Z")

</div>

[bugs://E22550](https://www.remobjects.com/portal/bugs/?id=E22550) was closed as fixed.
