Declare And Use Methods

Working in an object-oriented language, you will find three important concepts: properties, methods, and events. Methods hold operations that can have 0 to many input parameters and 0 to one return values. Methods enable the developer to hide (encapsulate) the difficulty of a coding task by placing complicated sections of code in a method. If the signature of the method (input parameters and return values) is well thought out, the developer can change how he implements the code and not affect the consumer of that method. If the developer has to change the signature of that method, the consumer of the method will not function any more, although this problem can be solved via overloaded functions. A signature change includes any of the following: adding or subtracting input parameters or return values;changing the data type of an input parameter or return value.

When you are new to ASP.NET development, you use many methods that are available from the .NET Framework. As you get comfortable with developing in ASP.NET, you will find that you will start creating your own custom methods. Taking this approach will reduce the number of lines you will have to write in your code and make the code itself easier to maintain.

DECLARE AND USE METHODS (CONTINUED)

DECLARE AND USE METHODS (CONTINUED)

—— Create the GetFormattedDate function, which returns a string.

—± Declare a string variable to hold the return value.

Create a case statement to handle the different types of formats.

—— Create the GetFormattedDate function, which returns a string.

—± Declare a string variable to hold the return value.

Create a case statement to handle the different types of formats.

Was this article helpful?

0 0

Post a comment