Advertisement
Hiteshw11

Generic Classes In Dart

Nov 25th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.22 KB | Source Code | 0 0
  1. void main() {
  2.   var num=Generic<int>(123);
  3.   num.write();
  4.  var num2=Generic<String>("Hitesh");
  5.   num2.write();
  6. }
  7.  
  8.  
  9. class Generic<T>
  10. {
  11.  
  12. T number;
  13.  
  14. Generic(this.number);
  15.  
  16. void write()
  17. {
  18. print("$number");
  19.  
  20. }
  21.  
  22. }
Tags: dart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement