I have defined the following method:
void Write(string fileContent, string fileName, string container = StorageBlobContainers.ProfilePictures)
The code compiled with no problem, so I wrote the code to execute it (from a diffferent file):
string json = JsonConvert.SerializeXNode(node);
FileProcessor.Write(json, "productscontainer");
But it seemed like for some reason it just did nothing.
After a few minutes of struggling to understand the problem, I finally found it. Somewhere in the same class, there was already a Write
function defined like this:
void Write(string filePath, string container = StorageBlobContainers.ProfilePictures)
{
if (!File.Exists(filePath))
return string.Empty;
...
This really confused me, as it did compile fine, and of course, it makes sense as one method has 3 parameter signature and the other one has 2, but isn't this very ambiguous and/or error prone? For me it seems like none of the methods are the "logical" one to choose. Why is the 2nd one chosen over the other?