- Home /
what is wrong whis this?
public List SampleMethod(List i){
     return i;
}
               Comment
              
 
               
              apart from the incomplete formatting of the posted code, you haven't defined a type for the List argument... 
Answer by Landern · Mar 02, 2016 at 04:23 PM
The List type would be considered a generic but does take a Type that makes up the List, it's strongly typed(unlike ArrayList).
if you were dealing with a List of Transform objects
 public List<Transform> SampleMethod(List<Transform> i)
 {
      return i;
 }
lets say it's a List of strings
 public List<string> SampleMethod(List<string> i)
 {
      return i;
 }
How about getting and returning a list of Transform from a list of GameObjects?
 public List<Transform> SampleMethod(List<GameObject> i)
 {
      i.Select(go => go.transform).ToList(); // Requires using System.Linq.  Returning IEnumerable would make more sense too.
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                