Click here to Skip to main content
15,893,381 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 codewitch30-Jul-19 17:07
mvahoney the codewitch30-Jul-19 17:07 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd30-Jul-19 17:23
Super Lloyd30-Jul-19 17:23 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch30-Jul-19 17:25
mvahoney the codewitch30-Jul-19 17:25 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd30-Jul-19 17:34
Super Lloyd30-Jul-19 17:34 
GeneralRe: i don't like object oriented programming Pin
honey the codewitch30-Jul-19 17:34
mvahoney the codewitch30-Jul-19 17:34 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd30-Jul-19 18:07
Super Lloyd30-Jul-19 18:07 
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
Super Lloyd31-Jul-19 2:05 
Yeah, I was wondering, isn't that good enough?!
But then I realised one could accidentally instantiate new FA<char, T>() instead of the desired new CharFA<T>()

But then what of this other syntax?
While it's slightly more wordy, I bet the end compiled result is just as you desired
C#
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);
    }
}

I mean personally I am happy to solve that using subclasses or interfaces, but since you really didn't want to....
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 2:17
mvahoney the codewitch31-Jul-19 2:17 
GeneralRe: i don't like object oriented programming Pin
Super Lloyd31-Jul-19 3:13
Super 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
Super 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
Super Lloyd31-Jul-19 5:05 
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
Super 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
Super 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
Super 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
Super 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 

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.