1
In the method Log there is the type parameter HttpClient. The function only uses the parameter to access the property BaseAddress, which is a Uri.
private void Log(string verb, HttpClient httpClient) {
var url = httpClient.BaseAddress.ToString();
Logging.LogInfo(GetType().Name, $"Iniciou requisição HTTP {verb} no endereço {url}");
}
Like everyone you call Log(string, HttpClient) also has access to HttpClient.BaseAddress, the method Log could be so:
private void Log(string verb, string url) {
Logging.LogInfo(GetType().Name, $"Iniciou requisição HTTP {verb} no endereço {url}");
}
and who calls him:
Log(HttpVerbs.Post, anotherHttpClient.BaseAddress.ToString());
That way, I wouldn’t pass the more complex object of the kind HttpClient but only what I care about, which is a string. I did it the first way, passing by HttpClient in case in the future I need more information from the HTTP client in the log.
Considering HttpClient the most complex type and string the simplest, what I want to know is whether there is a difference in performance and memory usage in both ways.
Is it the same thing to do with the complex object and the simplest object? Will any consume more or less memory? How is this treated in . NET?
It is all passed by reference, memory usage is not relevant.
– bfavaretto
https://answall.com/questions/14490/aloca%C3%A7%C3%A3o-de-mem%C3%B3ria-em-c-types-value-e-types-refer%C3%Aancia
– bfavaretto