TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mursaleen fayyaz
NA
84
125.2k
Type Information Operators
Jun 3 2013 1:25 PM
is , as , typeof , sizeof
The
is
Operator allow you to check whether an object is compatible with a specified type.
int i = 10;
if(i is object)
{
Console.WriteLine("i is an object");
}
The
as
Operator is used to perform explicit type conversions of reference types. If the type being converted is compatible with the specified type, conversion is performed successfully. However, if the types are incompatible, the as operator returns the value
null
.
object o1 = "Some string";
object o2 = 5;
string s1 = o1 as string; //successful conversion
string s2 = o2 as string; //null
The
sizeof
Operator
Console.WriteLine(sizeof(int));
with Complex types:
unsafe
{
Console.WriteLine(sizeof(Customer));
}
The
typeof
operator returns a System.Type object representing a specified type.
typeof(string) will return a Type object representing the System.String type.
Thanks for Viewing. Comments are appreciated.
Reply
Answers (
0
)
Tuples can combine objects of different types.
Null coalescing Operator