- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 81字
- 2021-07-15 17:05:34
Generic classes
Similar to generic interfaces, we can also define generic classes. We define classes with a generic type in angle brackets (<>) as follows:
class GenericClass<T> { add: (a: T, b: T) => T; }
var myGenericClass = new GenericClass<number>(); myGenericClass.add = function(a, b) { return a + b; };
Here, the generic class is instantiated by passing the generic data type as number. So, the add function will process and add two variables of type number passed as parameters.
推薦閱讀
- PHP動(dòng)態(tài)網(wǎng)站程序設(shè)計(jì)
- UML+OOPC嵌入式C語言開發(fā)精講
- PLC編程及應(yīng)用實(shí)戰(zhàn)
- Instant Ext.NET Application Development
- 利用Python進(jìn)行數(shù)據(jù)分析
- Unity 3D腳本編程:使用C#語言開發(fā)跨平臺(tái)游戲
- ASP.NET 4.0 Web程序設(shè)計(jì)
- PHP+MySQL動(dòng)態(tài)網(wǎng)站開發(fā)從入門到精通(視頻教學(xué)版)
- Mobile Forensics:Advanced Investigative Strategies
- 金融商業(yè)數(shù)據(jù)分析:基于Python和SAS
- R語言:邁向大數(shù)據(jù)之路
- Python機(jī)器學(xué)習(xí)
- Natural Language Processing with Python Cookbook
- JSP大學(xué)實(shí)用教程
- Microsoft Azure Security