I want to know the difference between calling a method within the same class using 'this.MethodName' and just the 'MethodName' in C#.
First Option
public class Transaction
{
public bool PerformTransaction(Model model)
{
//Calling the method name using 'this'
var refNumber = this.GetTransactionReferenceNumber(model);
//Method Implementation
}
private string GetTransactionReferenceNumber(Model model)
{
//Method Implementation
}
}
Second Option
public class Transaction
{
public bool PerformTransaction(Model model)
{
//Calling the method using it's name(without using 'this' keyword)
var refNumber = GetTransactionReferenceNumber(model);
//Method Implementation
}
private string GetTransactionReferenceNumber(Model model)
{
//Method Implementation
}
}
Which option should I use to call methods within the same class?. What is the difference between both options? and what is the best practice?