visual studio 2010 - Access function return type as Tuple in C# -


its naive question haven't used tuples before asking out. facing issue while accessing function return value tuple in function.

here code :

  public tuple<string, string, string> createtransaction()         {             var tcompresp = new tuple<string, string, string>(t, tcode, message);             return tcompresp; } 

now not sure how can access return values of above function in other page

  var tresp = new tuple<string, string, string>((objmanager.createtransaction()).item1, (objmanager.createtransaction()).item2, (objmanager.createtransaction()).item3); 

in above line access return tuple problem calling same function ( createtransaction() ) 3 times

so question how can function's tuple return value in single call?

 string trespon = objmanager.createtransaction()   ///suppose if return type string. 

i use value in function

update(trespon.item1, trespon.item2, trespon.item3); 

try this:

tuple<string,string,string> trespon = objmanager.createtransaction();  update(trespon.item1,trespon.item2,trespon.item3); 

createtransaction returns tuple<string,string,string> not string

always can use var instead tuple<string,string,string>

var trespon = objmanager.createtransaction(); 

note var way write it, not type.

but better way should using new class return data:

public class connectioninfo {    public string t;    public string code;    public string message; }  public connectioninfo createtransaction() {      var tcompresp = new connectioninfo{t=t, code=tcode, message=message};      return tcompresp; } 

then

var trespon = objmanager.createtransaction(); update(tresp.t, tresp.code, tresp.message); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -