Download presentation
Presentation is loading. Please wait.
Published byAmberly Parsons Modified over 9 years ago
1
VB and C# Programming Basics
2
Overview Basic operations String processing Date processing Control structures Functions and subroutines
3
Additional Documentation For extensive documentation in Microsoft.NET Development using VB or C#: –http://msdn.microsoft.com/en-us/library/dd642420.aspxhttp://msdn.microsoft.com/en-us/library/dd642420.aspx
7
The System Namespace Contains fundamental classes, including String and DateTime System Namespace Documentation –http://msdn.microsoft.com/en- us/library/system.aspxhttp://msdn.microsoft.com/en- us/library/system.aspx
8
String Processing Concatenation String length Substrings Changing case Replacing text Hyperlink to String class documentation
9
String concatenation
10
Note: C# is case sensitive. Length property begins with upper-case “L” Returning string lengths
11
Substring method of String class. 1 st argument = start position 2 nd (optional) argument = length of substring
12
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)
13
Changing case
14
Replacing text in a string
15
The DateTime Class Provides many useful properties and methods related to dates and times Hyperlink to DateTime documentation
16
Date Manipulation Lots of methods and properties for the DateTime class!
17
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
18
Control Structures Selection –if – else –select case ----- switch Looping –for loops –while and do while loops
19
Syntax for if statements in C# is identical to what you know from Java
20
VB Select-Case like before
21
Note: C# switch statement allows case to include strings…different from Java, which requires integral values
22
for loop syntax similar to what you know of Java
23
Note: unlike Java, C# includes a foreach keyword in the core language.
24
while in C# is similar to what you know already in Java
25
Functions and Subroutines Signatures – return type, name, parameter list Calling functions and subroutines Making use of return values
26
Note: with VB.NET, explicit type declarations not necessary Note the use of ToString method…converts numeric values to strings for text output.
27
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.
28
Array Processing Topics: –Array declaration, instantiation, initialization –Single-dimensional arrays –Multi-dimensional arrays –Jagged arrays
29
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
30
Single Dimension Arrays VB
31
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
32
Multi Dimension Arrays VB Length vs. GetLength(): Length returns full array size GetLength(x) returns nbr elements in row x
33
Jagged Arrays C# Jagged arrays are familiar to Java programmers
34
Jagged Arrays VB
35
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
36
Note initialization of server control properties in the Page_Load procedure Association of click event with event-handling routine
37
Resulting HTML code Resulting browser render
38
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: – To – This will enable compile errors in your code to be identified when attempting to view the page in a browser
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.