| Start |
|---|
| "anonymous object" + "dynamic keyword" solution You can return an anonymous object from your function And assign the result to a dynamic object and read the values in it. |
| Tuple solution You can return an instance of And read the values like below: |
| Ref and Out Parameters The Ref Parameter :-If you want to pass a variable as ref parameter then you need to initialize it before you pass it as ref parameter to method. Out Parameter :- If you want to pass a variable as out parameter you don’t need to initialize it before you pass it as out parameter to method. RemarksThere is no inherent answer in C# to this - so called - need. Nonetheless there are workarounds to satisfy this need. The reason I qualify the need as "so called" is that we only need methods with 2 or more than 2 values to return when we violate good programming principals. Especially the Single Responsibility Principle (opens new window). Hence, it would be better to be alerted when we need functions returning 2 or more values, and improve our design. |
Read Article
https://develop.horje.com/learn/1434/reference