Search code examples
c#.netstringreplacedecompiler

decompile .NET Replace method (v4.6.1)


I want to see how the

public String Replace(String oldValue, String newValue);

method that is inside mscorlib.dll (System.String) works.

I decompiled the mscorlib.dll with dotPeek and inside the method there is a call to ReplaceInternal method which I cannot find it

string s = ReplaceInternal(oldValue, newValue);

I have search for this method even on the open source .NET Core from GIT but no luck.

View my Decompiled code

Please explain where is this method and what is inside?


Solution

  • The extern C++ code is here.

    https://github.com/gbarnett/shared-source-cli-2.0/blob/master/clr/src/vm/comstring.cpp

    Line 1578 has

    FCIMPL3(Object*, COMString::ReplaceString, StringObject* thisRefUNSAFE, StringObject* oldValueUNSAFE, StringObject* newValueUNSAFE)