# Different representation of boolean when converted to .Net string

**URL:** https://talk.remobjects.com/t/different-representation-of-boolean-when-converted-to-net-string/1562
**Category:** Script for .NET
**Created:** [January 15, 2013, 7:13pm UTC](https://talk.remobjects.com/t/different-representation-of-boolean-when-converted-to-net-string/1562 "2013-01-15T19:13:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![luboid](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/l/9f8e36/32.png) [@luboid](https://talk.remobjects.com/u/luboid)
#### Post date: [January 15, 2013, 7:13pm UTC](https://talk.remobjects.com/t/different-representation-of-boolean-when-converted-to-net-string/1562/1 "2013-01-15T19:13:12Z")

</div>

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

namespace ToRemObjects  
{  
public class TestClass  
{  
double m;

```
    public double testProperty
    {
        get
        {
            return m;
        }
        set
        {
            m = value;
        }
    }
}

public class RemObjectsConsole
{
    Dictionary<object, object> bag = new Dictionary<object, object>();

    public RemObjectsConsole()
    {
    }

    public double propDouble
    {
        get { return 1.2D; }
        set { Console.WriteLine("propDouble:{0}", value); }
    }
    public double getDouble()
    {
        return 1.3D;
    }
    public void writeDouble(double value)
    {
        Console.WriteLine("writeDouble:{0}", value);
    }
    public double getDateAsDouble()
    {
        return 1357908756.0D;
    }
    public int getDateAsInt()
    {
        return 1357908756;
    }

    public int propInt
    {
        get { return 150; }
        set { Console.WriteLine("propInt:{0}", value); }
    }
    public int getInt()
    {
        return 150;
    }
    public void writeInt(int value)
    {
        Console.WriteLine("writeInt:{0}", value);
    }

    public string propString
    {
        get { return "string.value"; }
        set { Console.WriteLine("propString:{0}", (value == null ? "<<null>>" : value)); }
    }
    public void writeString(string value)
    {
        Console.WriteLine("writeString:{0}", (value == null ? "<<null>>" : value));
    }
    public string getString()
    {
        return "My get string...";
    }

    public bool propBoolean
    {
        get { return true; }
        set { Console.WriteLine("propBoolean:{0}", value); }
    }
    public void writeBoolean(bool value)
    {
        Console.WriteLine("writeBoolean:{0}", value);
    }
    public bool getBoolean()
    {
        return true;
    }

    public DateTime propDate
    {
        get { return new DateTime(1974, 1, 1); }
        set { Console.WriteLine("propDate:{0}", value); }
    }
    public void writeDate(DateTime value)
    {
        Console.WriteLine("writeDate:{0}", value);
    }
    public DateTime getDate()
    {
        return new DateTime(1974, 1, 1);
    }

    public object propObject
    {
        get { return this; }
        set { Console.WriteLine("propObject:{0}:{1}", (null == value ? "<<null>>" : value.GetType().Name), (null == value ? "<<null>>" : value)); }
    }

    public void writeObject(object value)
    {
        Console.WriteLine("writeObject:{0}:{1}", (null == value ? "<<null>>" : value.GetType().Name), (null == value ? "<<null>>" : value));
    }

    public override string ToString()
    {
        return "My Console.ToString to string ...";
    }

    public void load(string commandText, params object[] parameters)
    {
        // do somting...
        int i = 0;
    }

    public void load2(string commandText, object[] parameters)
    {
        // do somting...
        int i = 0;
    }

    public void loadStrings(params string[] parameters)
    {
        // do somting...
        int i = 0;
    }
    public void loadDoubles(params double[] parameters)
    {
        // do somting...
        int i = 0;
    }
    public void loadStrings2(string[] parameters)
    {
        // do somting...
        int i = 0;
    }

    public object this[string name]
    {
        get
        {
            object value;
            bag.TryGetValue(name, out value);
            return value;
        }
        set
        {
            bag[name] = value;
        }
    }

    public object this[int index]
    {
        get
        {
            object value;
            bag.TryGetValue(index.ToString(), out value);
            return value;
        }
        set
        {
            bag[index.ToString()] = value;
        }
    }

    public void ThrowException()
    {
        throw new ApplicationException("test exception ....");
    }
}

class Program
{
    static void Main(string[] args)
    {
        using (var esc = new RemObjects.Script.EcmaScriptComponent())
        {
            esc.Include("test1", @"

```

function testPropString(cc) {  
// JavaScript string representing boolean values are ‘false’ ‘true’

```
cc.propString = true;// lead to 'True'
cc.writeString(true);// lead to 'True'
cc.propString = false;// lead to 'False'
cc.writeString(false);// lead to 'False'

cc.propString = new Boolean(true);// lead to 'true'
cc.writeString(new Boolean(true));// lead to dirfferent presentation in string format 'True' when up one is 'true'
cc.propString = new Boolean(false);// lead to 'false'
cc.writeString(new Boolean(false));// lead to dirfferent presentation in string format 'False' when up one is 'false'

```

}  
");

```
            RemObjectsConsole cc = new RemObjectsConsole();
            var o = esc.RunFunction("testPropString", cc);
            Console.ReadLine();
        }
    }

}

```

}

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [January 18, 2013, 3:55pm UTC](https://talk.remobjects.com/t/different-representation-of-boolean-when-converted-to-net-string/1562/2 "2013-01-18T15:55:14Z")

</div>

Hello

Thanks again for perfect testcases.  
Fix has been uploaded to GitHub.  
At Monday we’ll put the built installer in your personal downloads folder.

Thanks for follow-ups

---

<div class="post-metadata">

### Author: ![luboid](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/l/9f8e36/32.png) [@luboid](https://talk.remobjects.com/u/luboid)
#### Post date: [January 19, 2013, 12:18pm UTC](https://talk.remobjects.com/t/different-representation-of-boolean-when-converted-to-net-string/1562/3 "2013-01-19T12:18:48Z")

</div>

Thanks for support
