Click here to Skip to main content
14,834,425 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 1:29
mvahoney the codewitch31-Jul-19 1:29 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 2:05
MemberSuper Lloyd31-Jul-19 2:05 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 2:17
mvahoney the codewitch31-Jul-19 2:17 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 3:13
MemberSuper Lloyd31-Jul-19 3:13 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 3:16
mvahoney the codewitch31-Jul-19 3:16 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 3:30
MemberSuper Lloyd31-Jul-19 3:30 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 3:35
mvahoney the codewitch31-Jul-19 3:35 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 5:05
MemberSuper Lloyd31-Jul-19 5: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 5:11
mvahoney the codewitch31-Jul-19 5:11 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 5:12
MemberSuper Lloyd31-Jul-19 5:12 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 5:14
mvahoney the codewitch31-Jul-19 5:14 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 5:15
MemberSuper Lloyd31-Jul-19 5:15 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 5:19
mvahoney the codewitch31-Jul-19 5:19 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 5:50
MemberSuper Lloyd31-Jul-19 5:50 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 5:53
mvahoney the codewitch31-Jul-19 5:53 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 5:56
mvahoney the codewitch31-Jul-19 5:56 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 6:01
MemberSuper Lloyd31-Jul-19 6:01 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:05
mvahoney the codewitch31-Jul-19 6:05 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 6:11
mvahoney the codewitch31-Jul-19 6:11 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 5:27
mvahoney the codewitch31-Jul-19 5:27 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 5:51
MemberSuper Lloyd31-Jul-19 5:51 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 5:11
MemberSuper Lloyd31-Jul-19 5:11 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 5:13
mvahoney the codewitch31-Jul-19 5:13 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch31-Jul-19 2:20
mvahoney the codewitch31-Jul-19 2:20 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd30-Jul-19 19:42
MemberSuper Lloyd30-Jul-19 19: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.