0% found this document useful (0 votes)
25 views1 page

If (O Is Fraction) ( (Fraction) O) .Show Fraction F o As Fraction If (F ! Null) F.Show

The document defines an object o initialized to an integer value. It uses the 'is' and 'as' operators to check and cast the type of o. When o is an integer, result of o is int is true. When o is cast to a string, it is not null. The priority table lists the associativity of C# operators from highest to lowest priority.

Uploaded by

Ariel Bedani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

If (O Is Fraction) ( (Fraction) O) .Show Fraction F o As Fraction If (F ! Null) F.Show

The document defines an object o initialized to an integer value. It uses the 'is' and 'as' operators to check and cast the type of o. When o is an integer, result of o is int is true. When o is cast to a string, it is not null. The priority table lists the associativity of C# operators from highest to lowest priority.

Uploaded by

Ariel Bedani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

object o = 123456;

Console.WriteLine(c.GetType()); // System.Int32
bool result = o is int; // operator "is"
Console.WriteLine(result); // True
o = "abcdef";
// string str = o; // Error
string str = o as string; // operator "as"
if ( str == null )
Console.WriteLine("o is not a string");
else
Console.WriteLine("o is a string {0}", str);

if( o is Fraction) Fraction F = o as Fraction


(( Fraction) o ).Show() if( F != null)
F.Show()

Priority Table
Category Operators Associativity
Primary x.y f(x) a[x] x++ x-- new
typeof checked unchecked
Unary + - ! ~ ++x --x (T)x
Multiplicative * / % left to right
Additive + - left to right
Shift << >> left to right
Relational and type testing < > <= >= is as left to right
Equality == != left to right
Logical AND & left to right
Logical XOR ^ left to right
Logical OR | left to right
Conditional AND && left to right
Conditional OR || left to right
Conditional ?: right to left
Assignment = *= /= %= += -= <<= >>= &= ^= |= right to left

You might also like