Skip to content
Loading
Return two values in static method
  • Suthahar Jegatheesan
    Hi Dinesh ,
     
    you can use below any approach  .
     
    1. you can use "Ref " keyword .
    2. you can Use "OUT" keywork .
    3. you can use return as object
    1. struct Assert    
    2. {    
    3.      public Array Product1;    
    4.      public Array Product2;    
    5. }     
    6. public static Assert LoadAssetAssignView()    
    7. {    
    8.        Assert values = new Assert();    
    9.        values.Product1= "somevalue";    
    10.        values.Product1= "Some value"    
    11.        return values;    
    12. }   
     4.Returning Tuple
     
    1. public Tuple<Array,ArrayLoadAssetAssignView()    
    2.        {    
    3.          
    4.            return new Tuple<ArrayArray>("somevalue", "somevalue");    
    5.        }   
     Thanks
    Sutahhar.j 
  • Hi Dinesh,
     
    You can return multi dimensional array.
    Alternatively you can create a class with two properties as following.
     
    1. public class DataClass  
    2. {  
    3.     public Array Property1 { getset; }  
    4.       
    5.     public Array Property2 { getset; }  
    6. }  
    And create an object of this class in your static method, populate the property and return the Object from the method. 
     
    1. public static Array LoadAssetAssignView()  
    2. {  
    3.     DataClass obj = new DataClass();  
    4.   
    5.     obj.Property1 = new Array();  
    6.     obj.Property2 = new Array();  
    7.   
    8.     return obj;  
    9. }  
    I hope this solves your issue.
      
    Thanks and regards,
    Chetan Ranpariya