-3

I recently changed from PHP to learn C#. I am trying to code a project for Bluetooth communication with framework 32feet. How to understand '(Stream)' in the code below? Thanks in advance!

   private void ReadMessagesToEnd_Runner(object state)
    {
        Stream peer = (Stream)state;
        ReadMessagesToEnd(peer);
    }
rock-paper
  • 93
  • 1
  • 9

2 Answers2

0

This is called type casting. It changes a variables type (including the whole mess that happens if it wasn't actually of that type.). You should read a good book or tutorial on C# before you continue.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
0

Your question is very vague, but I'll try my best to explain.

All classes are derived from Object in C#, thus any Object can be cast to any type. All the (Stream)state is doing above is taking the object state passed into the method and turning it into a Stream object.

If your question was actually asking what the Stream class is, please direct your attention to the Google search bar and type "C# Stream".

Luke Joshua Park
  • 9,527
  • 5
  • 27
  • 44