P. 1
C #

C #

5.0

|Views: 504|Likes:
Published by ahmed_nasser
ASP.Net C#
ASP.Net C#

More info:

Published by: ahmed_nasser on Apr 01, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/10/2014

pdf

text

original

C#

42

ADD REFERENCE TYPES

043601-X Ch03.F 10/18/01 11:58 AM Page 42

I The Class1.cs code
appears in the parent window.

Á Delete the comments
within the Main method.

‡ Type the code that
specifies strings and
concatenates them.

° Run the program by
pressing the F5 key.

I The concatenated string
appears on the screen.

· Save the program as the
filename.

WORKING WITH VISUAL C# BASICS 3

You can reverse the boxing process by using a process called
unboxing.Unboxing converts an object to a value type.When
Visual C# unboxes an object,it checks the object instance to
make sure that the instance is the boxed value of the given value
type (such as an integer),and then Visual C# copies the value of
the instance into the value type variable.

43

TYPE THIS:

using System;

public BoxClass

{

public static void Main()

{

int TiggerAge = 11;

object box = TiggerAge; // boxes the TiggerAge

value

int UnBoxedAge = (int)box; // Unboxes the

value

Console.WriteLine("The unboxed value is {0}",

UnBoxedAge);

}

}

RESULT:

The unboxedvalue is
11.

043601-X Ch03.F 10/18/01 11:58 AM Page 43

Console
Applicatio

⁄ Click Start Programs
Microsoft Visual Studio .NET
7.0 Microsoft Visual
Studio .NET 7.0.

¤ Click New Project in the
Start page.

I The New Project window
appears.

‹ Click the Console
Application icon in the
Templates pane.

› Type a name for your file.

ˇ Click OK.

Your program cannot operate without operators,which

are mathematical symbols that perform a wide variety
of functions.These operators compare,combine,and
contrast values so your program can make choices.For
example,your program can refuse to perform a particular
action if a user-entered value such as a password is not the
same as a stored password in a program.

C# places operators into sixteen different categories.Some
operators calculate arithmetical algorithms such as number
addition and subtraction.Some arithmetical operators let
you control calculation overflow errors,such as divide by
zero errors,that can cause a program crash.

Some operators are logical — they calculate whether a
condition is true or not such as a user ID number matching
the ID number on file within the program.Other operators
are relational and determine whether a value is greater
than,equal to,or less than another value.

Other operators assign values to variables by using the
equals sign or a combination of the equals sign and another
operator.For example,if you have the arguments x=1and
x+=6,then that is the equivalent of x= 1+6.

The most important operator of all is the new operator that
lets you create new objects,such as classes and variables,in
your program.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->