I am looking at some C # code at the moment, and I wanted to check that I am not going crazy in my understanding of how it should work.
This is to do with walking around System.ServiceModel.Channels.Message. Each method that accepts a Message object has a method signature similar to this:
void SomeMethod(ref Message message) { ... }
I do not understand why the keyword "ref" is there. As far as I understand, if the method will not completely replace the object, then it is not needed.
void SomeMethod(ref Message message)
{
message = new Message();
}
But if the message, for example, simply adds something else to the headers or simply reads the value from the object, then the keyword "ref" is not required, because Message is a reference type.
void SomeMethod(Message message)
{
message.Headers.Add("Some Data");
}
Greetings