Post on 03-Jan-2016
transcript
Overview
• Basic operations
• String processing
• Date processing
• Control structures
• Functions and subroutines
Additional Documentation
• For extensive documentation in Microsoft .NET Development using VB or C#:– http://msdn.microsoft.com/en-us/library/dd642420.aspx
The System Namespace
• Contains fundamental classes, including String and DateTime
• System Namespace Documentation– http://msdn.microsoft.com/en-us/library/
system.aspx
String Processing
• Concatenation
• String length
• Substrings
• Changing case
• Replacing text
• Hyperlink to String class documentation
Substring method of String class.
1st argument = start position
2nd (optional) argument = length of substring
Indexof method of String class
Returns the 0-based index position of the substring in the searched string.
Syntax:
searchedString.Indexof(stringToFind)
searchedString.Indexof (stringToFind, startPos)
The DateTime Class
• Provides many useful properties and methods related to dates and times
• Hyperlink to DateTime documentation
Additional Notes
• In C#, use DateTime.Parse static method to convert a string to date. Not necessary in VB.– Try changing from DateTime.Now to a string
representing a date and time
• To make the view source more readable, you can insert line breaks in your output string:– “\n” for C#
– ControlChars.CrLf for VB
Control Structures
• Selection– if – else– select case ----- switch
• Looping– for loops– while and do while loops
Note: C# switch statement allows case to include strings…different from Java, which requires integral values
Functions and Subroutines
• Signatures – return type, name, parameter list
• Calling functions and subroutines
• Making use of return values
Note: with VB .NET, explicit type declarations not necessary
Note the use of ToString method…converts numeric values to strings for text output.
Note that the int data type (and other primitive data types) provides the possibility of converting data to string via ToString(). In this sense it operates like a Java wrapper class.
Array Processing• Topics:
– Array declaration, instantiation, initialization– Single-dimensional arrays– Multi-dimensional arrays– Jagged arrays
Single Dimension Arrays C#Declaration in C# is strict, brackets must follow data type: int[] array1; NOT int array1[];
Looping through arrays can be done using Length property or via for each loop
Multi Dimension Arrays C#
Multi-dimension array declaration and use in C# is unlike Java. With Java you are always declaring jagged arrays, but C# has a feature for multi-dimension arrays
Multi Dimension Arrays VB
Length vs. GetLength():
Length returns full array sizeGetLength(x) returns nbr elements in row x
Web Server Controls for Assignment #1
• TextBox – Two Useful Properties:
• Text – contains the string for user input
• Columns – specifies visible number of characters
• Button– Event processing via ONCLICK attribute in
ASP:Button tag
• Label– Static text display
Note initialization of server control properties in the Page_Load procedure
Association of click event with event-handling routine
The web.config file
• Useful for deployment and configuration• Primarily for web administration• Can also be used for creating global application variables• XML file• If used, should be placed in application’s root folder• For debugging purposes, you should do the following……• In your web.config file, change the tag that says:
– <customErrors mode="RemoteOnly" /> • To
– <customErrors mode="Off"/>• This will enable compile errors in your code to be identified when
attempting to view the page in a browser