Introduction to C#
Download
Report
Transcript Introduction to C#
Introduction to C#
Tuc Goodwin
5/1/2020
1
Agenda
Upcoming Schedule
Syntax Differences
Exiting programs/methods/loops
Member Scope
Conditional Statements
Indexes and Arrays
Control Characters
Loops
Inheritance
Overloading
Summary
Upcoming Schedule
Intro to C# (November)
Debugging .NET 2.0 (December)
Serializations (January)
Object Thinking (February)
ADO.NET Revisited (March)
Let’s look at some code!
Syntax Differences
Case Sensitivity
Line Termination
Comments
Namespace Declaration and Usage
Variable Declaration
Variable Initialization
Declaring Function Parameters
Exiting Programs/Methods/Loops
VB.Net – End
VB/C# - System.Environment.Exit(1)
VB.Net – Exit For / Exit Function
C# - break;
C# - continue;
Member Scope
C#
VB.Net
Comments
public
Public
Default in VB
private
Private
Default in C#
internal
Friend
protected
Protected
protected internal
Protected Internal
C# vs. VB.Net
Static vs. Shared
static in C#
Shared in VB.Net
Classes vs. Modules
class
Module
Conditional Statement
VB.Net – If <condition> Then
:
Else
:
End If
C# - if( <condition>)
{
}
else
{
}
Operators || Short Circuiting
VB.Net
C#
Operator
And
&&
and
Or
||
or
Not
!
not
=
==
equals
<>
!=
not equal
if (DoTask() || DoTask2())
{
}
If DoTask() or DoTask2() Then…
Ternary Operators
Visual Basic Immediate IF
IIF(true/false), value for true, value for false
C# (true/false clause)? Value for true: value for false;
Indexes and Arrays
Indexes
VB.Net use parenthesis (n)
C# use brackets [n]
Arrays
string[] phones = {“1”,”2”,”3”};
phones = new string[3];
Loops
for(int count=1, count < 20; count++)
{
}
for( string count=“”, count !=“done”;)
{
}
string[] names = new string[5];
foreach(string onename in names)
{…}
Control Characters
C# escape sequence
VB constant
Purpose
\n
Lf
New line
\r
Cr
Carriage return
\r\\n
NewLine or CrLf
Carriage return – new line
\*
Quote
Quotation marks
\\
\t
Backslash character
Tab
Tab
Type Comparison
VB.Net – Ctype()
GetType()
C# - typeof()
Object Oriented - Inheritance
Class Checking : Account
{
…
}
Class Checking Inherits Account
…
End Class
Object Oriented - Overloading
public void MakeDeposit(int Amount){}
public void MakeDeposit(ref int Amount, int
AmountAvailable){}
Sub MakeDeposit (ByVal Amount as Integer)
End Sub
Sub MakeDeposit (ByVal Amount as Integer,
AmountAvailable as Integer)
End Sub
Summary
We…
5/1/2020
17
Other Resources
www.microsoft.com/net
msdn.microsoft.com/net
www.gotdotnet.com
support.microsoft.com/webcasts
www.dnug.net
www.devx.com/dotnet/
www.thedotnetmag.com
www.winnetmag.com
www.microsoft.com/mspress
Next Time…
We will continue to build from here…
Debugging .NET 2.0
5/1/2020
19
Questions?
5/1/2020
20