# Get an error saying that array is obj when it should return a bool

**URL:** <https://forum.kirupa.com/t/get-an-error-saying-that-array-is-obj-when-it-should-return-a-bool/264686>\
**Category:** Uncategorized\
**Created:** [June 28, 2008, 6:46pm UTC](https://forum.kirupa.com/t/get-an-error-saying-that-array-is-obj-when-it-should-return-a-bool/264686 "2008-06-28T18:46:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrRobot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drrobot/32/3907_2.png) [@DrRobot](https://forum.kirupa.com/u/DrRobot)\
**Post date:** [June 28, 2008, 6:46pm UTC](https://forum.kirupa.com/t/get-an-error-saying-that-array-is-obj-when-it-should-return-a-bool/264686/1 "2008-06-28T18:46:57Z")

</div>

Alright, i am working with an array and some keyvalues. and i keep getting an error from the last funciton saying:

```auto

Cannot implicitly convert type 'object' to 'bool'. An explicit conversion exists (are you missing a cast?) (CS0266)

```

```auto

**[SIZE=2][COLOR=#008000]using [/COLOR][/SIZE]**[SIZE=2]System[/SIZE][SIZE=2][COLOR=#006400];[/COLOR][/SIZE]
**[SIZE=2][COLOR=#008000]using [/COLOR][/SIZE]**[SIZE=2]System[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]Collections[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]Generic[/SIZE][SIZE=2][COLOR=#006400];[/COLOR][/SIZE]
**[SIZE=2][COLOR=#008000]using [/COLOR][/SIZE]**[SIZE=2]System[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]Drawing[/SIZE][SIZE=2][COLOR=#006400];[/COLOR][/SIZE]
**[SIZE=2][COLOR=#008000]using [/COLOR][/SIZE]**[SIZE=2]System[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]Windows[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]Forms[/SIZE][SIZE=2][COLOR=#006400];[/COLOR][/SIZE]
**[SIZE=2][COLOR=#008000]using [/COLOR][/SIZE]**[SIZE=2]System[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]Diagnostics[/SIZE][SIZE=2][COLOR=#006400];[/COLOR][/SIZE]
**[SIZE=2][COLOR=#008000]namespace [/COLOR][/SIZE]**[SIZE=2]Test[/SIZE][SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080]/// < **summary** >[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080]/// [/COLOR][/SIZE][SIZE=2][COLOR=#008000]Description of MainForm.[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080]/// < **/summary** >[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE]**[SIZE=2][COLOR=#000080]partial [/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]class [/COLOR][/SIZE][SIZE=2]MainForm : Form[/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
 
**[SIZE=2][COLOR=#ff0000]int [/COLOR][/SIZE]**[SIZE=2]i [/SIZE][SIZE=2][COLOR=#006400]= [/COLOR][/SIZE][SIZE=2][COLOR=#00008b]0[/COLOR][/SIZE][SIZE=2][COLOR=#006400];[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]private [/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]bool [/COLOR][/SIZE]**[SIZE=2]running [/SIZE][SIZE=2][COLOR=#006400]= [/COLOR][/SIZE]**[SIZE=2][COLOR=#008b8b]true[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400];[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE]**[SIZE=2]Array keyArray [/SIZE][SIZE=2][COLOR=#006400]= [/COLOR][/SIZE][SIZE=2]Array[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]CreateInstance[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE]**[SIZE=2][COLOR=#008b8b]typeof[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2]**[SIZE=2][COLOR=#ff0000]bool[/COLOR][/SIZE]**[/SIZE][SIZE=2][COLOR=#006400]), [/COLOR][/SIZE][SIZE=2][COLOR=#00008b]2[/COLOR][/SIZE][SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2][COLOR=#00008b]222[/COLOR][/SIZE][SIZE=2][COLOR=#006400]);[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#191970]MainForm[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]()[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]//[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]// The InitializeComponent() call is required for Windows Forms designer support.[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]//[/COLOR][/SIZE]
 
**[SIZE=2][COLOR=#191970]InitializeComponent[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]();[/COLOR][/SIZE]
 
**[SIZE=2][COLOR=#0000ff]for [/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2]i[/SIZE][SIZE=2][COLOR=#006400]=[/COLOR][/SIZE][SIZE=2][COLOR=#00008b]0[/COLOR][/SIZE][SIZE=2][COLOR=#006400]; [/COLOR][/SIZE][SIZE=2]i[/SIZE][SIZE=2][COLOR=#006400]<[/COLOR][/SIZE][SIZE=2][COLOR=#00008b]222[/COLOR][/SIZE][SIZE=2][COLOR=#006400]; [/COLOR][/SIZE][SIZE=2]i[/SIZE][SIZE=2][COLOR=#006400]++)[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
[SIZE=2]keyArray[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]SetValue[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE]**[SIZE=2][COLOR=#008b8b]false[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2][COLOR=#00008b]0[/COLOR][/SIZE][SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2]i[/SIZE][SIZE=2][COLOR=#006400]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]
 
**[SIZE=2][COLOR=#191970]onEnterFrame[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]();[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE]**[SIZE=2][COLOR=#ff0000]void [/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]onEnterFrame[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]()[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]while[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2]running[/SIZE][SIZE=2][COLOR=#006400])[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]keyisdown[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2][COLOR=#00008b]39[/COLOR][/SIZE][SIZE=2][COLOR=#006400]))[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
[SIZE=2]Debug[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]WriteLine[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]"Right is pressed"[/COLOR][/SIZE][SIZE=2][COLOR=#006400]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE]**[SIZE=2][COLOR=#a52a2a]override [/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]void [/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]OnKeyDown[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2]KeyEventArgs e[/SIZE][SIZE=2][COLOR=#006400])[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
[SIZE=2]Debug[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]WriteLine[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2]e[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]KeyValue[/SIZE][SIZE=2][COLOR=#006400]);[/COLOR][/SIZE]
[SIZE=2]keyArray[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]SetValue[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE]**[SIZE=2][COLOR=#008b8b]true[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2][COLOR=#00008b]0[/COLOR][/SIZE][SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2]e[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]KeyValue[/SIZE][SIZE=2][COLOR=#006400]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE]**[SIZE=2][COLOR=#a52a2a]override [/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]void [/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]OnKeyUp[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2]KeyEventArgs e[/SIZE][SIZE=2][COLOR=#006400])[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
[SIZE=2]keyArray[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]SetValue[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE]**[SIZE=2][COLOR=#008b8b]false[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2][COLOR=#00008b]0[/COLOR][/SIZE][SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2]e[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE][SIZE=2]KeyValue[/SIZE][SIZE=2][COLOR=#006400]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]
**[SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]bool [/COLOR][/SIZE][SIZE=2][COLOR=#191970]keyisdown[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE]**[SIZE=2][COLOR=#ff0000]int [/COLOR][/SIZE]**[SIZE=2]X[/SIZE][SIZE=2][COLOR=#006400])[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]{[/COLOR][/SIZE]
[SIZE=2][COLOR=#000080]return [/COLOR][/SIZE][SIZE=2]keyArray[/SIZE][SIZE=2][COLOR=#006400].[/COLOR][/SIZE]**[SIZE=2][COLOR=#191970]GetValue[/COLOR][/SIZE]**[SIZE=2][COLOR=#006400]([/COLOR][/SIZE][SIZE=2][COLOR=#00008b]0[/COLOR][/SIZE][SIZE=2][COLOR=#006400], [/COLOR][/SIZE][SIZE=2]X[/SIZE][SIZE=2][COLOR=#006400]);[/COLOR][/SIZE]
[SIZE=2][COLOR=#006400]}[/COLOR][/SIZE]

```

i’m not sure how to fix that little problem

---

<div class="post-metadata">

**Author:** ![DrRobot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drrobot/32/3907_2.png) [@DrRobot](https://forum.kirupa.com/u/DrRobot)\
**Post date:** [June 28, 2008, 10:44pm UTC](https://forum.kirupa.com/t/get-an-error-saying-that-array-is-obj-when-it-should-return-a-bool/264686/2 "2008-06-28T22:44:04Z")

</div>

Nevermind, i have it figured out. i should’ve just made the Array a bool[,] (i did, thats how it was fixed).
