- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 80字
- 2025-04-04 18:04:54
Working with different data types
Now, let's put a <T> symbol after where it says public class GenericsClass, as follows:
public class GenericsClass<T>
This means that this single class can work equally well with several different data types. Next, enter the following beneath the open curly brace under the preceding line:
private T[] vals;
Enter the following comment directly above this line:
//generic array instance variable
In other words, this will operate equally well on doubles, decimals, integers, and so on.