I have a small function that looks something like this:
void Bar(string s) { */ do somthing with the string here.*/ } void Foo() { Bar("Hello"); }
If I look at the output of IL, it gives me the following:
.method private hidebysig instance void Foo() cil managed { .maxstack 8 L_0000: ldarg.0 L_0001: ldstr "Hello" L_0006: call instance void TestApp.MainWindow::Bar(string) L_000b: ret }
now I thought I would replace it with a const string field for it.
const string str= "Hello"; void Foo() { Bar(str); }
which converts to the EXACT MOST IL fragment.
Now my question is which one to use?
Foo("Hello"); or Foo(cHello);
Thank you for your help!
-------------- EDIT -------------------
To be more specific, I use this for logging to add a prefix to the message: And it will only appear in the code!
so that it looks something like this:
void LogDebug(string msg) { Log("[DEBUG]", msg) } void Log(string pre, string msg) {
:)
source share