Need help in reading the com port

I'm a beginner in programming and I made my Arduino to write to an external program through com8. Now the external program (also in c#) is also writing back to the same com8. I need help in reading this values on the arduino board i.e. I want to be able to write to com port and read the external values that is coming to com port at the same time.

I want to be able to write to com port and read the external values that is coming to com port at the same time.

First off, the Arduino can not do two things "at the same time". Nor can the PC, for that matter. The things it does can be done close enough together the appear to the human user to be simultaneous.

You use the Serial.print(), Serial.write(), and Serial.println() functions to send data from the Arduino to the PC, via the serial port. You use Serial.available() to see how much data there is in the serial port receive buffer, and Serial.read() to read that data one byte (char) at a time.

So in that case, do I have to use different com ports? for example, use com8 to write to the external program, and use com3 to read what the external program is sending back. Will that work?

The Arduino has one serial port. You read from and write to it on the same port.

So how do you suggest I do this? i really need to write, and read

Which end are you having problems with?

Writing to the serial port from C# is trivial.

Reading from the serial port on the Arduino is equally trivial, if you know what functions to use, and I told you in the 1st reply which functions to use.

What are you trying to do and just how simultaneous do the read and write have to be?

I'm trying to simulate a process for a virtual simulator system. So instead of connecting actual sensors to the arduino, and have it send the readings to an external application(a game engine), I wrote a random number generator on the arduino, and had it written to the com port. And it works fine in the external application. Now, I need to also get some values from the external application, and send it to arduino. I already did that too. The only thing left is for Arduino to read these values
Thanks

Then the serial functions that PaulS mentioned are what you need, just be careful to avoid the classic mistake and don't assume that serial data has arrived - use Serial.available to be sure it has.