# Double convertTo.int?(Help)

**URL:** <https://discourse.mcneel.com/t/double-convertto-int-help/123939>\
**Category:** Scripting\
**Tags:** windows, csharp\
**Created:** [May 10, 2021, 6:19am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939 "2021-05-10T06:19:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![architect.civil5](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/architect.civil5/32/500786_2.png) [@architect.civil5](https://discourse.mcneel.com/u/architect.civil5)\
**Post date:** [May 10, 2021, 6:19am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939/1 "2021-05-10T06:19:03Z")

</div>

I want Covert(double to int )… For use as index(Because the Random number produced from Double)  
how?

 ![index](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/7/a/97a640922d61f25bd67114c9041c45f191b61484.jpeg)  
[covert.int.gh](https://discourse.mcneel.com/uploads/short-url/jLsFT3xKgjEytYTp70iKFm6KsOM.gh) (9.4 KB)

```auto
  private void RunScript(int seed, double lenght, double v, Interval domain, ref object A, ref object B)
  {
    Vector3d pt = new Vector3d();
    var rnd = new Random(seed);
    var list = new List<double>();
    List < Vector3d > vx = new List <Vector3d>{new Vector3d(v, 0, 0),new Vector3d(-v, 0, 0),new Vector3d(0, v, 0),new Vector3d(0, -v, 0),new Vector3d(0, 0, v),new Vector3d(0, 0, -v)};

    double index;

    for(var i = 0; i < 6; i++)
    {
      list.Add(domain.ParameterAt(rnd.NextDouble()));
    }

    index = Math.Round(list[0], 0);
    int indexN = Convert.ToInt(index);

    pt = vx[indexN];
    A = pt;
    B = index; 

```

---

<div class="post-metadata">

**Author:** ![Baris](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/baris/32/772765_2.png) [@Baris](https://discourse.mcneel.com/u/Baris)\
**Post date:** [May 10, 2021, 6:22am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939/2 "2021-05-10T06:22:54Z")

</div>

int myInteger =(int) myDouble;

---

<div class="post-metadata">

**Author:** ![architect.civil5](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/architect.civil5/32/500786_2.png) [@architect.civil5](https://discourse.mcneel.com/u/architect.civil5)\
**Post date:** [May 10, 2021, 6:27am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939/3 "2021-05-10T06:27:51Z")

</div>

thanks 💯

---

<div class="post-metadata">

**Author:** ![Dani\_Abalde](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dani_abalde/32/759411_2.png) [@Dani\_Abalde](https://discourse.mcneel.com/u/Dani_Abalde)\
**Post date:** [May 10, 2021, 7:13am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939/4 "2021-05-10T07:13:47Z")

</div>

[Convert.ToInt **32** ()](https://docs.microsoft.com/en-us/dotnet/api/system.convert.toint32?view=net-5.0).

---

<div class="post-metadata">

**Author:** ![architect.civil5](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/architect.civil5/32/500786_2.png) [@architect.civil5](https://discourse.mcneel.com/u/architect.civil5)\
**Post date:** [May 10, 2021, 7:34am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939/5 "2021-05-10T07:34:01Z")

</div>

And other questions = How is the equivalent of this phrase in C #?  
python=

```auto
if y in x:
    a="true"
else:
    a="false"

```

**and in c# how?**

```auto

    if(y in x)
    { A = "Ture";}
    else
    { A = "false";}

```

[test in List.gh](https://discourse.mcneel.com/uploads/short-url/964gKRh0bQPwkrr1lJXKmNyEYl3.gh) (8.2 KB)

 ![tesrt](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/6/a/36a9706370e56103a7bbcfed5bc6bea898dce48a.jpeg)

---

<div class="post-metadata">

**Author:** ![Dani\_Abalde](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dani_abalde/32/759411_2.png) [@Dani\_Abalde](https://discourse.mcneel.com/u/Dani_Abalde)\
**Post date:** [May 10, 2021, 7:36am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939/6 "2021-05-10T07:36:37Z")

</div>

if(x.[Contains](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.contains?view=net-5.0)(y)) I guess

---

<div class="post-metadata">

**Author:** ![architect.civil5](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/architect.civil5/32/500786_2.png) [@architect.civil5](https://discourse.mcneel.com/u/architect.civil5)\
**Post date:** [May 10, 2021, 7:39am UTC](https://discourse.mcneel.com/t/double-convertto-int-help/123939/7 "2021-05-10T07:39:31Z")

</div>

🙏 🙏 THANKS
