November 2017
Intermediate to advanced
800 pages
30h 51m
English
Generics can be used for methods, even inside a non-generic type.
In PacktLibrary, add a new class named Squarer, with a generic method named Square, as shown in the following code:
using System;using System.Threading;namespace Packt.CS7{ public static class Squarer { public static double Square<T>(T input) where T : IConvertible { double d = input.ToDouble( Thread.CurrentThread.CurrentCulture); return d * d; } }}
Note the following:
Read now
Unlock full access