Click here to Skip to main content
15,881,172 members
Home / Discussions / C#
   

C#

 
NewsC# vNext language design - private protected - FamilyAndAssembly Pin
Paulo Morgado30-Apr-14 10:46
professionalPaulo Morgado30-Apr-14 10:46 
GeneralRe: C# vNext language design - private protected - FamilyAndAssembly Pin
Richard Deeming1-May-14 1:03
mveRichard Deeming1-May-14 1:03 
GeneralRe: C# vNext language design - private protected - FamilyAndAssembly Pin
Paulo Morgado1-May-14 6:21
professionalPaulo Morgado1-May-14 6:21 
QuestionString, Why does this work?? Pin
GrooverFromHolland30-Apr-14 8:53
GrooverFromHolland30-Apr-14 8:53 
AnswerRe: String, Why does this work?? Pin
BillWoodruff30-Apr-14 9:58
professionalBillWoodruff30-Apr-14 9:58 
GeneralRe: String, Why does this work?? Pin
GrooverFromHolland30-Apr-14 10:16
GrooverFromHolland30-Apr-14 10:16 
GeneralRe: String, Why does this work?? Pin
Rob Philpott1-May-14 1:51
Rob Philpott1-May-14 1:51 
AnswerRe: String, Why does this work?? Pin
Alan N1-May-14 0:58
Alan N1-May-14 0:58 
The concatenation operators are replaced by calls to one of the overloaded string.Concat methods. There are versions with string or object parameters, e.g Concat(string, string, string), Concat(object, object, object), and if possible the more efficient (string, string, ...) versions will be used.

This gives us, well me really, the opportunity to play with ILDASM and have a look at what the C# compiler decides to do.

C#
private static String StringConcat(String a, String b, String c) {
  return a + b + c;
}

private static String ObjectConcat(String a, int b, DateTime c) {
  return a + b + c;
}


and the IL shows the use of the different Concat methods.

.method private hidebysig static string  StringConcat(string a,
                                                     string b,
                                                     string c) cil managed
{
  // Code size       9 (0x9)
  .maxstack  8
  IL_0000:  ldarg.0
  IL_0001:  ldarg.1
  IL_0002:  ldarg.2
  IL_0003:  call       string [mscorlib]System.String::Concat(string,
                                                              string,
                                                              string)
  IL_0008:  ret
} // end of method ConcatTest::StringConcat

.method private hidebysig static string  ObjectConcat(string a,
                                                      int32 b,
                                                      valuetype [mscorlib]System.DateTime c) cil managed
{
  // Code size       19 (0x13)
  .maxstack  8
  IL_0000:  ldarg.0
  IL_0001:  ldarg.1
  IL_0002:  box        [mscorlib]System.Int32
  IL_0007:  ldarg.2
  IL_0008:  box        [mscorlib]System.DateTime
  IL_000d:  call       string [mscorlib]System.String::Concat(object,
                                                              object,
                                                              object)
  IL_0012:  ret
} // end of method ConcatTest::ObjectConcat


Alan.
Questionwriting to a file while Looping Pin
Kasun Liyanage30-Apr-14 7:35
Kasun Liyanage30-Apr-14 7:35 
AnswerRe: writing to a file while Looping Pin
OriginalGriff30-Apr-14 8:07
mveOriginalGriff30-Apr-14 8:07 
GeneralRe: writing to a file while Looping Pin
Kasun Liyanage30-Apr-14 8:31
Kasun Liyanage30-Apr-14 8:31 
GeneralRe: writing to a file while Looping Pin
OriginalGriff30-Apr-14 8:39
mveOriginalGriff30-Apr-14 8:39 
QuestionPower point file formatter Pin
Taimoor Hassun29-Apr-14 18:21
Taimoor Hassun29-Apr-14 18:21 
AnswerRe: Power point file formatter Pin
Richard MacCutchan29-Apr-14 20:26
mveRichard MacCutchan29-Apr-14 20:26 
GeneralRe: Power point file formatter Pin
Taimoor Hassun29-Apr-14 21:00
Taimoor Hassun29-Apr-14 21:00 
GeneralRe: Power point file formatter Pin
Richard MacCutchan29-Apr-14 21:08
mveRichard MacCutchan29-Apr-14 21:08 
GeneralRe: Power point file formatter Pin
Taimoor Hassun30-Apr-14 4:54
Taimoor Hassun30-Apr-14 4:54 
GeneralRe: Power point file formatter Pin
Chris Quinn30-Apr-14 4:57
Chris Quinn30-Apr-14 4:57 
GeneralRe: Power point file formatter Pin
Taimoor Hassun30-Apr-14 6:17
Taimoor Hassun30-Apr-14 6:17 
Questionhelp me Pin
Member 1078417429-Apr-14 14:18
Member 1078417429-Apr-14 14:18 
AnswerRe: help me Pin
Peter Leow29-Apr-14 14:36
professionalPeter Leow29-Apr-14 14:36 
AnswerRe: help me Pin
OriginalGriff29-Apr-14 20:10
mveOriginalGriff29-Apr-14 20:10 
AnswerRe: help me Pin
Rob Philpott30-Apr-14 2:17
Rob Philpott30-Apr-14 2:17 
GeneralRe: help me Pin
Pete O'Hanlon30-Apr-14 6:35
mvePete O'Hanlon30-Apr-14 6:35 
GeneralRe: help me Pin
Wes Aday30-Apr-14 14:27
professionalWes Aday30-Apr-14 14:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.