What you are looking for is called a generic method (you can also have generic classes, you should be able to find some good info online about generics).
To make something generic is pretty simple, all you do is add right after the method name (or after the class name if working with classes). Then that T can be used as a Type. This is how the GetComponent method is made.
Example code: public T[] AddToArray<T> (T[] newArray, T newTransform) { ... }
A couple of things to note. It does not have to be a T, it can be anything, full normal names even. However, doing so is not considered good, or standard practice in C#.
You can also have multiple generics by simply adding a comma like you would with most things <T, K>.
Hope this was helpful, I suggest looking up more about generics, they are pretty cool. Let me know if you have any other questions!