# Case Statement Issue - 'hidden' CRLF in input stream?

**URL:** https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393
**Category:** C#
**Created:** [March 14, 2021, 5:16am UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393 "2021-03-14T05:16:52Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [March 14, 2021, 5:16am UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/1 "2021-03-14T05:16:53Z")

</div>

Has anyone encountered this particular issue in Water/Fire with the Case Statement in Hydrogen(C#). It appears there may be some hidden character in the standard input stream that is tripping the Default statement to be evaluated (see attached pic)? I used a Trim function to strip any possible CRLF’s, but to no avail. I copied the program to VS C#, VS REMObjects C# as well as JetBrains Rider - and they all work as expected. The problem seems to be relegated to the Water and Fire IDE’s - they both exhibit the same behavior on my PC Desktop as well as on my MacBook Pro laptop.

 ![2021-03-13 23_54_24-C__Users_chike_OneDrive_Documents_RemObjects Software_Elements_Water_CaseStateme](https://talk.remobjects.com/uploads/default/original/2X/3/3efac290d7f07253a6ee4b07389aacae26ce4702.png)

```
namespace CaseStatementTest1
{
    static class Program
    {
        public static void Main(string[] args)
        {
           int totalAttempts = 3;
           string doorChoice;
           
           for (int i = 1 ; i <= totalAttempts; i++ )
           {
               Console.Write($"Choose a door between 1 - 5 and win a prize! This is attempt #{i}: ");
               doorChoice = Console.ReadLine();
               doorChoice = doorChoice.Trim(); // attempt to strip CRLF characters from input stream
               
               
               switch (doorChoice)
               {
                   case "1":
                       Console.WriteLine("You win a balloon!" );
                       break;
                   case "2":
                       Console.WriteLine("You win a stuffed animal!" );
                       break;
                   case "3":
                       Console.WriteLine("You win a bicycle!" );
                       break;
                   case "4":
                       Console.WriteLine("You win a car!" );
                       break;
                   case "5":
                       Console.WriteLine("You win a million dollars!" );
                       break;
                   default:
                       Console.WriteLine("That's not even a choice. You win nothing!" );
                       break;
               }
               Console.WriteLine();
           }
           Console.ReadLine();
           Console.ReadLine(); //Two needed in Fire/Water to prevent Terminal from prematurely closing
        }
    }
}

```

---

<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: [March 14, 2021, 1:58pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/2 "2021-03-14T13:58:59Z")

</div>

Curious; I’d love to hear what it turns out the problem was, here?

---

<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: [March 14, 2021, 1:59pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/3 "2021-03-14T13:59:12Z")

</div>



---

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [March 14, 2021, 4:25pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/4 "2021-03-14T16:25:03Z")

</div>

Hey Marc, I posted a bit too prematurely. So, I’m doing some more research on this lovely Spring-forward Sunday to narrow the problem down … 🤓

---

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [March 14, 2021, 6:55pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/5 "2021-03-14T18:55:23Z")

</div>

OK, I believe I’ve narrowed it down. The issue seems to occur when the code is generated using the “Template: Console Application (Windows) - RemObjects.Hydrogene.Island.Windows.ConsoleApplication”.

 ![2021-03-14 13_39_46-C__Users_chike_Documents_RemObjects Software_Elements_Water_CaseStatement1_Bin_D](https://talk.remobjects.com/uploads/default/original/2X/c/c883405c037b12739f39f66d9d841fbf0065c5c6.png)

Here’s a Dropbox link: [CaseStatement using Windows Console](https://www.dropbox.com/sh/ztd1xa51c4pr3oc/AADEoKGTbtC2GFn9eObx5Y-9a?dl=0)

The Case Statement code runs as expected when using the Classic\_Net framework template.

 ![2021-03-14 14_51_14-C__Users_chike_Documents_RemObjects Software_Elements_Water_CaseStatementNETClas](https://talk.remobjects.com/uploads/default/original/2X/0/0ed512530e2b76da73a6e894c684ff2ca369a21f.png)

Here’s a Dropbox link: [CaseStatement using Classic\_Net](https://www.dropbox.com/sh/a8youpozskgfhr8/AAC0eH0RN83u_IxZSkwqM4vOa?dl=0)

Also, of note, is that the Windows Console program requires two ‘Console.ReadLine()’ methods to prevent the Terminal from prematurely closing. As where, the Classic\_Net program only requires one 'Console.ReadLine() which leads me to believe there’s an errant CRLF somewhere in the Windows Console version. 🤓

---

<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: [March 14, 2021, 10:47pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/6 "2021-03-14T22:47:05Z")

</div>

Will have a look in the morning, thanx!

---

<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: [March 15, 2021, 1:01pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/7 "2021-03-15T13:01:56Z")

</div>

This sounds like a bug in ReadLine on Island/Windows (or Island in general), yeah…

FWIW, on Mac I can not reproduce this, I changed your code to::

```auto
           writeLn(1);
           Console.ReadLine();
           writeLn(2);
           //Console.ReadLine(); //Two ReadLines needed to prevent Terminal from prematurely closing which leads me to believe there's a 'hidden' CRLF

```

and it emits “1”, I press enter once, and then it emits “2” and quits. Will test on Windows later in the day when I boot up my VM…

Side quesrtion: what version are you on, latest 2611? (not that think much changed here in the past few weeks that would effect this…)

---

<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: [March 15, 2021, 1:23pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/8 "2021-03-15T13:23:43Z")

</div>

Definitely something flaky, I get this:

 ![image](https://talk.remobjects.com/uploads/default/original/2X/b/bba7e344c4420fc52a04b7fb8aa3ae0f8a0397cb.png)

I press 1 once, and the “not a valid choice” comes as a second message right away. I then press ` again and it exits right away.

It seems where you get one too few enters, I get too many…

---

<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: [March 15, 2021, 1:23pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/9 "2021-03-15T13:23:50Z")

</div>

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

---

<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: [March 15, 2021, 1:26pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/10 "2021-03-15T13:26:42Z")

</div>

yep, “1”

results in two readlines, one with “1” and one empty:"

 ![image](https://talk.remobjects.com/uploads/default/original/2X/3/357871a204704339ab3cbfc68c1b1283a7293b7a.png)

---

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [March 15, 2021, 5:31pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/11 "2021-03-15T17:31:51Z")

</div>

Hey Marc, I’m using version .2605 Water and .2611 Fire. Thank you for looking into this and I’m glad you were able to confirm the issue. Cheers 🤓

---

<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: [March 15, 2021, 6:11pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/12 "2021-03-15T18:11:39Z")

</div>

Gary,

> [@chikega](#):
>
> Hey Marc, I’m using version .2605 Water and .2611 Fire. Thank you for looking into this and I’m glad you were able to confirm the issue. Cheers 🤓

FWIW, I can repro the with .2611 on Windows too (was a few builds behind before), same as above. But I cannot reproduce this on Mac, When you say Fire, do you mean building the app as Island/macOS, or as Island/Windows and running remotely.?

For me, the issue seems specific to Windows.

---

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [March 15, 2021, 6:19pm UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/13 "2021-03-15T18:19:01Z")

</div>

That’s correct … I was running Parallels on my Mac. So composing in Fire but building for Island/Windows which executed in Windows Parallel. That’s why I stated I was a bit premature with my first post of this thread and narrowed it down to Island/Windows only 😄

---

<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: [April 9, 2021, 9:34am UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/14 "2021-04-09T09:34:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Diego\_Navarro](https://talk.remobjects.com/user_avatar/talk.remobjects.com/diego_navarro/32/11766_2.png) [@Diego\_Navarro](https://talk.remobjects.com/u/Diego_Navarro)
#### Post date: [April 9, 2021, 9:36am UTC](https://talk.remobjects.com/t/case-statement-issue-hidden-crlf-in-input-stream/24393/15 "2021-04-09T09:36:44Z")

</div>

Sorry for the delay, the fix will be included in today’s build
