Re: String concatination

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



There is not operator + in the string class.
When you write code like

string a = "A";
string b = "B";
string c = a + b;

the C# compiler is who translates this code in a call to the Concat string's
member function.

Here is the IL code:

..method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code Size: 21 byte(s)
.maxstack 2
.locals (
string text1,
string text2,
string text3)
L_0000: ldstr "A"
L_0005: stloc.0
L_0006: ldstr "B"
L_000b: stloc.1
L_000c: ldloc.0
L_000d: ldloc.1
L_000e: call string string::Concat(string, string)
L_0013: stloc.2
L_0014: ret
}



The C++ compiler doesn't do this magic ;).


--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org


.



Relevant Pages

  • s: AT&T C++ string class std::string compatible
    ... I am on the lookout for a string class. ... that can be linked and/or compiled with that old compiler. ... "least cost" or some types of free licence would be very welcome;-) ...
    (alt.comp.lang.learn.c-cpp)
  • operator=
    ... Suppose I have a string class that has two '=' overloads; ... If my copy target is another CTheClass object, ... This implies that 2 is not required, and that the compiler ... My first question is whether this is behaviour, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: AT&T C++ string class std::string compatible
    ... > Hi friends, ... > I am on the lookout for a string class. ... > that can be linked and/or compiled with that old compiler. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: String Functions in MF
    ... Al Dev and others list method prototypes. ... the String class is from Al Dev. ... compiler and is not done at run-time. ...
    (comp.lang.cobol)
  • Re: What makes a compiler, was Is Assembler
    ... then calls another compiler to do the compilation process, ... formally a compiler just translates one computer language into ... an assembler translates into the machine code ...
    (comp.compilers)