Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
class
class
string , Exception
참조형식 interface
Reference
array
Type
delegate
mo1
42 Hello
c1 = null ; c1
6.12 4.2
O 6.12 4.2
Different
O 6.12 4.2
loc.x = 2 ; loc.y = 3 ;
PassCoordinateByValue (loc) ; loc
Console.WriteLine(loc.x + " , " + loc.y) ;
Exception Class
String Class
Common String Methods, Operators, and
Properties
String Comparisons
String Comparison Operators
Exception is a Class
Exception Objects Are Used to Raise Exceptions
• Create an Exception object by using new
• Throw the object by using throw
Exception Types Are Subclasses of Exception
• InvalidCastException, DivideByZeroException..
string s = “Hello” ;
s[0] = ‘c’ : // Compile-time error
Brackets
Insert Methods
Length Property
Copy Method
Concat Method
Trim Method
ToUpper and ToLower Methods
Equals Method
• Value comparison
• if (s1.Equals(s2)) //instance method
• if (String.Equals(s1,s2)) //static method
Compare Method
• More comparison
• Case-insensitive option
• Dictionary ordering
Locale-Specific Compare Options
string a = “Test” ;
string b = “Test” ;
if ( a == b ) …. // Returns true
Object
SystemException
System.IO Namespace
System.Xml Namespace
System.Data Namespace
Other Useful Namespace
XML Support
Various XML-Related Standards
System.Data.SqlClient
• SQL Server .NET Data Provider
System.Data
• Consists mostly of the classes that constitute
the ADO.NET architecture
System Namespace
System.Net Namespace
System.Net.Sockets Namespace
System.Windows.Forms Namespace
Impilcit Conversions
Explicit Conversions
• Cast operator
Exceptions
System.Convert Class
• Handles the conversions internally
Parent - General
Child - Specific
Bird b ;
if ( a is Bird )
b = ( Bird ) a ; // Safe
else
Console.WriteLine (“Not a Bird”) ;
InvalidCastException
Bird b = a as Bird ;
if ( b == null )
Console.WriteLine (“Not a Bird”) ;
object ox ;
ox = a ; b = (Bird) ox ;
ox = (object) a ; b = ox as Bird ;
ox = a as object ;
IVisual v = ( IVisual ) r ;
v.Move ( ) ; //not valid
v.Paint ( ) ; // ok
int p = 123 ;
object box ; 123 p = ( int ) box ;
box = p ;
box 123
implicit conversion
Value = Value
explicit conversion