Oui - Vous pouvez le voir explicitement en utilisant ILDASM.
Exemple:
Voici un programme qui ressemble à votre exemple suivi du code de CIL compilé:
Note: J'utilise la fonction String.Concat() juste pour voir comment le compilateur traite les deux méthodes différentes de concaténation.
Programme
class Program
{
static void Main(string[] args)
{
string s = "test " + "this " + "function";
string ss = String.Concat("test", "this", "function");
}
}
ILDASM
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 29 (0x1d)
.maxstack 3
.locals init (string V_0,
string V_1)
IL_0000: nop
IL_0001: ldstr "test this function"
IL_0006: stloc.0
IL_0007: ldstr "test"
IL_000c: ldstr "this"
IL_0011: ldstr "function"
IL_0016: call string [mscorlib]System.String::Concat(string,
string,
string)
IL_001b: stloc.1
IL_001c: ret
} // end of method Program::Main
Remarquez comment à IL_0001 le compilateur créé la constante "test de cette fonction", par opposition à la façon dont le compilateur traite le String.Concat () function - qui crée une constante pour chacun des paramètres .Concat(), puis appelle la fonction .Concat().
Même avec VB.NET je suppose, non? – Larsenal
Incertain - c'est un problème de langue, pas un problème de cadre. –
Attention si je change la question en C#? – Larsenal