Serial communication

I have tried to use a IR receiver with a TV remote and I succeed.
Now I want to use a C# GUI I made to get results from arduino, I mean:

1 - I use a TV remote to send signal to the IR receiver on the arduino
the library decodes de signals for me and I get the TV remote decimal values

2 - the IR receiver shows at serial monitor which TV remote button I pressed
if(results.value == 183873615) { Serial.println(“Button 1 pressed”); }

3 - from the if statement above, I send the byte “0” to serial port
C# should get this byte from serial port and do label1.Text = “button 1 pressed”;

Now theres the problem, C# doesn’t do anything. I explain:

I power my arduino from USB, and I see in my case COM4 is the arduino.
On the other side, at C# code I can use a line Serial.open(); but I get an error saying I can’t open it

My question is, if I power the arduino through USB, can I use that same COM port to use Serial communication between Arduino <–> C# ??

I want to know that. Later I can post my arduino and C# code. I followed some tutorials and both codes are similar, but C# doesn’t get anything from serial port

Thanks in advance

My question is, if I power the arduino through USB, can I use that same COM port to use Serial communication between Arduino <–> C# ??

Generally speaking, on a windows machine a single com port can only be opened by one application at a time.

Yes , as per the last post, you will have to close the serial Monitor window in the Arduino IDE before you can open the COM port in your C# program.