Methods
In this section we'll review:
- What are methods - a better way to organize code
- We'll extract the order validate logic, to the ValidateOrderDateMethod
protected override void OnSavingRow()
{
- if (u.Year( Orders.OrderDate) < 1990 || Orders.OrderDate.Year>2020)
- {
- Message.ShowError("Invalid Year");
- }
ValidateOrderDate();
}
void ValidateOrderDate()
{
if (u.Year(Orders.OrderDate) < 1990 || Orders.OrderDate.Year > 2020)
{
Message.ShowError("Invalid Year");
}
}
- Demo how to use the "ExtractMethod" automatic refactoring from Visual Studio
- Method with return value
- Introducing Regions
- Using CSharp 6 features to write shorter methods
- Expressions are migrated to methods
Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com