Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 .NET4 ASP:NET
i have three textboxes............in one textbox i input value 1000
and on its TextBox1_TextChanged i want to calculate values (1000+10%of1000) on textbox2
 
and (1000+20%of1000) on textbox3 and want to use only one method cal and want this method to be in a class
 
and in TextBox1_TextChanged: through class object method cal should be invoked
is this possible
pls tell
regards
Posted 2-Jan-13 1:25am
Comments
jibesh at 2-Jan-13 7:30am
   
to return multiple values from a method is simple and you can achieve that using the ref keyword is that what you want? is that enough for you?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

To return multiple values you can use either ref or out keyword as your arguments eg:
 
you can use /out
void ReturnMultiple(out string value1,out int value2,out flow value3)
{
   value1 = "value1";
   value2 = 0;
   value3 = 100.0f;
}
or
void ReturnMultiple(ref string value1,ref int value2,ref flow value3)
{
   value1 = "value1";
   value2 = 0;
   value3 = 100.0f;
};
 
Read more about 'ref' and 'out' Keywords here
What is the difference between the ref and out keywords in C#?[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Protected Void TextBox1_TextChanged(Sender s,Object e)
{
 
Str= CalculateBoth(val1,val2,val3);
string[] words = str.Split(',');
Txt1.Text=words[0];
Txt2.Text=words[1];
} 
static void CalculateBoth(int a,int b,int c)
{
int d=a + b % c;
int e=a + (b+10) % c;
string str= convert.toString(d) + "," + convert.toString(e);
return str;   
}
 
This Is For Example You can Do Like This...
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 404
1 Nirav Prabtani 389
2 Abhinav S 210
3 PIEBALDconsult 160
4 Dave Kreskowiak 155
0 OriginalGriff 7,580
1 Sergey Alexandrovich Kryukov 6,806
2 Maciej Los 3,919
3 Peter Leow 3,693
4 CHill60 2,742


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100