Click here to Skip to main content
14,361,266 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 2:29
memberhoney the codewitch31-Jul-19 2:29 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 3:05
memberSuper Lloyd31-Jul-19 3:05 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 3:17
memberhoney the codewitch31-Jul-19 3:17 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 4:13
memberSuper Lloyd31-Jul-19 4:13 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 4:16
memberhoney the codewitch31-Jul-19 4:16 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 4:30
memberSuper Lloyd31-Jul-19 4:30 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 4:35
memberhoney the codewitch31-Jul-19 4:35 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 6:05
memberSuper Lloyd31-Jul-19 6:05 
well.. my assembly is a bit rusty (or almost non existent) I will let you judge...

But here my test C# code
class A<T>
{
    public void Do(T value)
    {
        if (value is int intV) Do(intV);
        else DoDefault(value);
    }
    void DoDefault(T value)
    {
        Console.WriteLine("Value: " + value);
    }
    void Do(int value)
    {
        Console.WriteLine("Int: " + value);
    }
}
class Program
{
    static void Main(string[] args)
    {
        A<int> a = new A<int>();
        a.Do(1);

        A<double> b = new A<double>();
        b.Do(1.0);
    }
}

here is the code for a.Do(1) and b.Do(1.0) using go to disassembly in visual studio
            a.Do(1);
00F70898  mov         ecx,dword ptr [ebp-40h]<br />
00F7089B  mov         edx,1<br />
00F708A0  cmp         dword ptr [ecx],ecx<br />
00F708A2  call        00F70478<br />
00F708A7  nop  
            b.Do(1.0);
00F708C3  fld         qword ptr ds:[0F708E8h]<br />
00F708C9  sub         esp,8<br />
00F708CC  fstp        qword ptr [esp]<br />
00F708CF  mov         ecx,dword ptr [ebp-44h]<br />
00F708D2  cmp         dword ptr [ecx],ecx<br />
00F708D4  call        00F704A0<br />
00F708D9  nop  

I think there is no (assembly) if statement and direct execution of the relevant if (type) branch....
A new .NET Serializer
All in one Menu-Ribbon Bar
Taking over the world since 1371!

GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:11
memberhoney the codewitch31-Jul-19 6:11 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 6:12
memberSuper Lloyd31-Jul-19 6:12 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:14
memberhoney the codewitch31-Jul-19 6:14 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 6:15
memberSuper Lloyd31-Jul-19 6:15 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:19
memberhoney the codewitch31-Jul-19 6:19 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 6:50
memberSuper Lloyd31-Jul-19 6:50 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:53
memberhoney the codewitch31-Jul-19 6:53 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:56
memberhoney the codewitch31-Jul-19 6:56 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 7:01
memberSuper Lloyd31-Jul-19 7:01 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 7:05
memberhoney the codewitch31-Jul-19 7:05 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 7:11
memberhoney the codewitch31-Jul-19 7:11 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:27
memberhoney the codewitch31-Jul-19 6:27 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 6:51
memberSuper Lloyd31-Jul-19 6:51 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 6:11
memberSuper Lloyd31-Jul-19 6:11 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:13
memberhoney the codewitch31-Jul-19 6:13 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 3:20
memberhoney the codewitch31-Jul-19 3:20 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd30-Jul-19 20:42
memberSuper Lloyd30-Jul-19 20:42 

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.