2

It is just a theoretical question as asked to me during an interview. Basically, say we have two APIs and we referenced both DLLs in our application. Both these apis have same namespace, same class, and same methods. In such case, how will I differentiate between the methods when consuming them?

e.g. I have a class that calculates tax for consumers, and another that calculates tax for business. Both of them have a function TaxNameSpace.TaxClass.GetTaxRate(). Now, if I referenced both these dlls at the same time, and I want to call these functions, how will I notify runtime which function to choose.

jitendragarg
  • 945
  • 1
  • 14
  • 54
  • 1
    That is a pretty silly interview question. Nonetheless, what happened when you replicated this (created two DLLs with the same namespace, class, method etc and added references to both of them from a third project)? – mjwills Jul 06 '17 at 13:35
  • @mjwills I have not tried recreating it yet. I will try that and edit the question. And yes, I know. I actually told the interviewer that this situation might not occur at all. But quite possibly he might have had this issue. – jitendragarg Jul 06 '17 at 13:38
  • 1
    Read up on https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias . I have never used that in the 10+ years I have written C#. That is an insane interview question - since the only people who would know the answer are the 20 people in the world who ever ran into the problem... – mjwills Jul 06 '17 at 13:41
  • @mjwills Okay. Created a test solution. It throws an error when I try to reference the method. Now the problem is how to fix that. – jitendragarg Jul 06 '17 at 13:51
  • @mjwills Thanks. That actually does solve the problem. Funny thing is neither of us ran into this situation, but apparently it is enough of an issue to have an official solution. – jitendragarg Jul 06 '17 at 13:59

0 Answers0