Which two way I can use to make a method return a int and string.
1
Expert's answer
2017-09-08T11:18:07-0400
/*first way is to use out parameters*/ public void GetStringAndInt(out int intVar, out string stringVar) { intVar = 123; stringVar = "abc"; }
/*second way is a function that returns your own class*/ public IntAndString GetStringAndInt() { var intAndString = new IntAndString(); intAndString.intVal = 123; intAndString.stringVal = "abc"; return intAndString; }
public class IntAndString { public int intVal { get; set; } public string stringVal { get; set; } }
/*third way - use a Tuple class (availibale from 4.0 framework)*/ public Tuple<int, string> GetStringAndInt() { return Tuple.Create(123, "abc"); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment