I have a class that adds information to a list and then does some calculations. Now I want to return that to the original program. How do I do that?
In Main program I have public value
public string ResponseTime
{
get { return _ResponseTime; }
set { _ResponseTime = value; }
}
MAIN FUNCTION()
Within the main function I call the class which calculates the correct response time and returns it back. The question is how do I capture it in this main program?
ListTest.CalculateResponseTim开发者_开发百科e(_ResponseTime);
- need to use the value that returns and set ResponseTime to that value.
public static string CalculateResponseTime(string responseTime)
{
}
Are you just asking how to get the return value from a function??
ResponseTime = ListTest.CalculateResponseTime(_ResponseTime);
pass the parameter by reference
public void CalculateResponseTime(ref string responseTime)
{
// your code
}
you don't need to return the string, becuase when your modify the value of your string in the function ,the value will be modified the the original location (memory address) and not only in the scope of your function.
In this way you can assign directly the property of your class as function parameter, and when the function ends your property has the value modified too.
The alternative is passing your parameter as value and return the reult as assign of your property.
if you need more information about it. MSDN is your friend
ResponseTime = [insert calculated value]
(...at least, that's how I'm interpreting your question...)
精彩评论