LupusRex
Member
- Joined
- Oct 30, 2019
- Messages
- 16
- Programming Experience
- Beginner
Hi
I've been coding in Autoit for more than a decade, and have just started to use C#.
My Q. is when is it best practice to use return from a method, and when to use get; set from a method?
What I mean with this is:
In Autoit it's best practice to avoid the usage of Global variables to handle data used in methods (Functions), it's better to use Return to return the data to the calling function.
But then Autoit is single threaded and not OOP.
In C# I have the classes and can use the get; set; for variables, is that better than "throw" data between methods?
Example:
In Autoit I would do some thing like this.
In C# I could do the same, but I could also
private string Data { get; Set; }
and the do a Console.WriteLine(Data);
What is best to use in C# Return or get; set;
The reason for my asking is that I have a lot of methods in where I get some data, and then sends it to another method for processing, aso - and finally I return the data to my main method, where I then do the finale handling of the data.
Currently I use the Return statement in 90% of my methods.
Hope that my Question is clear
Cheers
/LR
I've been coding in Autoit for more than a decade, and have just started to use C#.
My Q. is when is it best practice to use return from a method, and when to use get; set from a method?
What I mean with this is:
In Autoit it's best practice to avoid the usage of Global variables to handle data used in methods (Functions), it's better to use Return to return the data to the calling function.
But then Autoit is single threaded and not OOP.
In C# I have the classes and can use the get; set; for variables, is that better than "throw" data between methods?
Example:
In Autoit I would do some thing like this.
C#:
$sData = GetData()
ConsoleWrite($sData) or just ConsoleWrite(GetData())
Func GetData()
$sReadString = FileRead("C:\Test.txt")
Return $sReadString
End Func
In C# I could do the same, but I could also
private string Data { get; Set; }
and the do a Console.WriteLine(Data);
What is best to use in C# Return or get; set;
The reason for my asking is that I have a lot of methods in where I get some data, and then sends it to another method for processing, aso - and finally I return the data to my main method, where I then do the finale handling of the data.
Currently I use the Return statement in 90% of my methods.
Hope that my Question is clear
Cheers
/LR