Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
Jibesh 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?

To return multiple values you can use either ref or out keyword as your arguments eg:

you can use /out
C#
void ReturnMultiple(out string value1,out int value2,out flow value3)
{
   value1 = "value1";
   value2 = 0;
   value3 = 100.0f;
}
or
C#
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#?[^]
 
Share this answer
 
C#
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...
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900