Click here to Skip to main content
15,910,009 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to start process Pin
joon vh.21-Mar-07 8:21
joon vh.21-Mar-07 8:21 
GeneralRe: how to start process Pin
Narchaithi22-Mar-07 6:46
Narchaithi22-Mar-07 6:46 
AnswerRe: how to start process Pin
Keshav V. Kamat21-Mar-07 22:43
Keshav V. Kamat21-Mar-07 22:43 
QuestionCompiler issue? Pin
Chadwick Posey21-Mar-07 8:03
Chadwick Posey21-Mar-07 8:03 
AnswerRe: Compiler issue? [modified] Pin
joon vh.21-Mar-07 8:11
joon vh.21-Mar-07 8:11 
GeneralRe: Compiler issue? Pin
Chadwick Posey21-Mar-07 8:21
Chadwick Posey21-Mar-07 8:21 
GeneralRe: Compiler issue? Pin
joon vh.21-Mar-07 8:56
joon vh.21-Mar-07 8:56 
GeneralRe: Compiler issue? Pin
Chadwick Posey21-Mar-07 9:26
Chadwick Posey21-Mar-07 9:26 
Code sample:
<br />
PrintArg(0);<br />
PrintArg((int)0);<br />
PrintArg((Int16)0);<br />
PrintArg((short)0);<br />
PrintArg((Int32)0);<br />
PrintArg((long)0);<br />
PrintArg((Int64)0);<br />
PrintArg(1);<br />


Corresponding IL:
<br />
.method public hidebysig static void  Main() cil managed<br />
{<br />
  .entrypoint<br />
  // Code size       85 (0x55)<br />
  .maxstack  1<br />
  IL_0000:  nop<br />
  IL_0001:  ldc.i4.0<br />
  IL_0002:  call       void Program::PrintArg(valuetype Foo)<br />
  IL_0007:  nop<br />
  IL_0008:  ldc.i4.0<br />
  IL_0009:  call       void Program::PrintArg(valuetype Foo)<br />
  IL_000e:  nop<br />
  IL_000f:  ldc.i4.0<br />
  IL_0010:  box        [mscorlib]System.Int16<br />
  IL_0015:  call       void Program::PrintArg(object)<br />
  IL_001a:  nop<br />
  IL_001b:  ldc.i4.0<br />
  IL_001c:  box        [mscorlib]System.Int16<br />
  IL_0021:  call       void Program::PrintArg(object)<br />
  IL_0026:  nop<br />
  IL_0027:  ldc.i4.0<br />
  IL_0028:  call       void Program::PrintArg(valuetype Foo)<br />
  IL_002d:  nop<br />
  IL_002e:  ldc.i4.0<br />
  IL_002f:  conv.i8<br />
  IL_0030:  box        [mscorlib]System.Int64<br />
  IL_0035:  call       void Program::PrintArg(object)<br />
  IL_003a:  nop<br />
  IL_003b:  ldc.i4.0<br />
  IL_003c:  conv.i8<br />
  IL_003d:  box        [mscorlib]System.Int64<br />
  IL_0042:  call       void Program::PrintArg(object)<br />
  IL_0047:  nop<br />
  IL_0048:  ldc.i4.1<br />
  IL_0049:  box        [mscorlib]System.Int32<br />
  IL_004e:  call       void Program::PrintArg(object)<br />
  IL_0053:  nop<br />
  IL_0054:  ret<br />
} // end of method Program::Main<br />


Notice the lack of a box operation any time the Int32 0 value is used... consistent with the call to the wrong function void Program::PrintArg(valuetype Foo)... but notice the correct box op for the call with 1!?!?

Quirky... I am almost convinced this is a compiler bug.

The only work around I can think of is to do the following:
<br />
using System;<br />
<br />
enum Foo { Bar, None }<br />
class Program<br />
{<br />
    static void PrintArg(object x) <br />
    { <br />
        if (x is Foo) <br />
        { <br />
            PrintFooArg((Foo)x); <br />
            return; <br />
        } <br />
        Console.WriteLine(x.ToString()); <br />
    }<br />
    <br />
    static void PrintFooArg(Foo x) <br />
    { <br />
        Console.WriteLine(x.ToString()); <br />
    }<br />
<br />
    public static void Main()<br />
    {<br />
        PrintArg(0);<br />
        PrintArg((int)0);<br />
        PrintArg((Int16)0);<br />
        PrintArg((short)0);<br />
        PrintArg((Int32)0);<br />
        PrintArg((long)0);<br />
        PrintArg((Int64)0);<br />
        PrintArg(1);<br />
        PrintArg(Foo.Bar);<br />
    }<br />
}<br />


It prints everything as expected....

=============================
I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

GeneralRe: Compiler issue? Pin
joon vh.21-Mar-07 9:08
joon vh.21-Mar-07 9:08 
GeneralRe: Compiler issue? Pin
Chadwick Posey21-Mar-07 9:58
Chadwick Posey21-Mar-07 9:58 
QuestionRe: Compiler issue? Pin
Chadwick Posey22-Mar-07 4:18
Chadwick Posey22-Mar-07 4:18 
AnswerRe: Compiler issue? Pin
joon vh.23-Mar-07 7:18
joon vh.23-Mar-07 7:18 
GeneralRe: Compiler issue? Pin
Chadwick Posey23-Mar-07 13:22
Chadwick Posey23-Mar-07 13:22 
JokeRe: Compiler issue? Pin
joon vh.23-Mar-07 16:22
joon vh.23-Mar-07 16:22 
QuestionSimple question about data DataSet, DataView and DataGrid Pin
goldoche21-Mar-07 7:44
goldoche21-Mar-07 7:44 
AnswerRe: Simple question about data DataSet, DataView and DataGrid Pin
Keshav V. Kamat21-Mar-07 22:41
Keshav V. Kamat21-Mar-07 22:41 
QuestionTextBox.OnTextChanged - No stack overflow?? Pin
Shy Agam21-Mar-07 7:34
Shy Agam21-Mar-07 7:34 
AnswerRe: TextBox.OnTextChanged - No stack overflow?? Pin
Edmundisme21-Mar-07 7:45
Edmundisme21-Mar-07 7:45 
GeneralRe: TextBox.OnTextChanged - No stack overflow?? Pin
Shy Agam21-Mar-07 8:03
Shy Agam21-Mar-07 8:03 
GeneralRe: TextBox.OnTextChanged - No stack overflow?? Pin
Dave Kreskowiak21-Mar-07 8:12
mveDave Kreskowiak21-Mar-07 8:12 
GeneralRe: TextBox.OnTextChanged - No stack overflow?? Pin
Shy Agam21-Mar-07 8:19
Shy Agam21-Mar-07 8:19 
GeneralRe: TextBox.OnTextChanged - No stack overflow?? Pin
Edmundisme21-Mar-07 8:25
Edmundisme21-Mar-07 8:25 
QuestionPutting Project Under Configuration Control Pin
ross.anderson21-Mar-07 7:34
ross.anderson21-Mar-07 7:34 
QuestionHow do I respond to a protocol like http://, but more like myProtocol:// ? Pin
Program.X21-Mar-07 7:18
Program.X21-Mar-07 7:18 
AnswerRe: How do I respond to a protocol like http://, but more like myProtocol:// ? Pin
Chadwick Posey21-Mar-07 8:11
Chadwick Posey21-Mar-07 8:11 

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.