-
April 2nd, 2016, 02:54 AM
#1
Multiple Method Calling
Hi Guys,
I'm a beginner in C# Language and studying/learning it for past 1 month via Internet.. To make myself understand it clearly skipping theoretical part I'm trying to develop multiple simple things and working on them and finding issues and optimizing codes and learn also..
So I'm stuck on some issues for which I googled and didn't find appropriate answer also I need some expert advice to guide me.
My first issue/query is.
I have created a multiple methods which are in series to do a work
Code:
void button_click()
{
method1();
await Task.delay // to let my GUI Unfreeze
method2();
await Task.delay // to let my GUI Unfreeze
method3();
}
void method1()
{ //code }
void method2()
{ //code }
void method3()
{ //code }
So is my above way of calling my method is correct.
My second issue is
Code:
void button_click()
{
Sort();
await Task.delay // to let my GUI Unfreeze
Replace();
await Task.delay // to let my GUI Unfreeze
Show();
}
void method1()
{
//code
Fetchdata();
}
void method2()
{
//code
FetchData2();
}
void method3()
{ //code }
void FetchData()
{ //code }
void FetchData2()
{ //code }
In My above code i used some other method calling in a method to parse/find text value from my file in order to use in next method.. But if value is return null then i need it to go to previous method in order to complete code from 1st method correctly. But if i do something like this
void FetchData()
{ //code
if (data1 == null)
Replace();
}
Go To method1 and calling fetchdata inside method1 and if fetchdata returns null then go to method1 else go to method2 similarly after method2 is called go to fetchdat1 inside method2 and if fetchdata1 returns null then go to method1 else go to method3... What would be correct way to do this.
Please Help me as I'm thinking of this and making my self confuse more.
Please and Thanks..
-
April 2nd, 2016, 11:34 AM
#2
Re: Multiple Method Calling
Put the individual parts of the functionality inside methods that does only that part (and does nothing else such as call other methods).
Then write a method that controls the other methods (detects successes and failures of each part method and calls the appropriate method (s)).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|