samedi 17 mars 2018

Generic method/class custom implementation for specified type

Is there any way to make this code compile or some other alternative. This implementation is only a example.

namespace ConsoleApp3
{
    using System;

    public static class Temp<T>
        where T : struct
    {
        public static T GetDefault()
            => throw new NotImplementedException(); // common implementation

        public static int GetDefault()
            => default; // custom implementation for specified type
    }
}





Aucun commentaire:

Enregistrer un commentaire