Jibu P C_Adoor Jibu P C_Adoor - 1 year ago 82
C# Question

Method should return multiple values


I have method in C#, I have to return multiple values from that method with out using collections like arrays. Is there any reliable way ?

Answer Source

Well, you could use:

  • a custom class/struct/type, containing all your values
  • out parameters


class MyValues
    public string Val1 { get; set; }
    public int Val2 {get; set; }

public MyValues ReturnMyValues();


public void ReturnMyValues(out string Val1, out int Val2);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download