Click here to Skip to main content
15,889,863 members
Home / Discussions / C#
   

C#

 
Questionneed help with Windows Service Pin
hut22328-Jan-06 16:57
hut22328-Jan-06 16:57 
QuestionRemoting - Start / Stop Server Pin
Skoder28-Jan-06 16:26
Skoder28-Jan-06 16:26 
Question[Message Deleted] Pin
g00fyman28-Jan-06 16:00
g00fyman28-Jan-06 16:00 
QuestionCasting term vs Boxing/Unboxing - terminology question Pin
LuluSailor28-Jan-06 15:03
LuluSailor28-Jan-06 15:03 
AnswerRe: Casting term vs Boxing/Unboxing - terminology question Pin
Dave Kreskowiak28-Jan-06 18:57
mveDave Kreskowiak28-Jan-06 18:57 
GeneralRe: Casting term vs Boxing/Unboxing - terminology question Pin
LuluSailor29-Jan-06 7:35
LuluSailor29-Jan-06 7:35 
GeneralRe: Casting term vs Boxing/Unboxing - terminology question Pin
Dave Kreskowiak29-Jan-06 9:22
mveDave Kreskowiak29-Jan-06 9:22 
AnswerRe: Casting term vs Boxing/Unboxing - terminology question Pin
Guffa29-Jan-06 0:38
Guffa29-Jan-06 0:38 
First let's look at the two different kinds of data types:

Value type: A simple data type that is stored as-is, like an int.

Reference type: A pointer (which is basically an int) that points to memory allocated on the heap, that contains the actual data.

Casting reference types in .NET is somewhat different than in most other platforms. The objects in .NET contains their own datatype information, so the type of the reference only determines how you use the object, not the actual type of the object. This means that in .NET you can only cast a reference to the actual class or one of its base classes, not to some completely different class.

Then let's look at the different ways of casting:

:: Casting a value type to another value type. Most numeric value types can be casted to other numeric value types. This is actually more of a conversion than a cast.

:: Casting an object to any of its base classes, for an example casting an HtmlButton to an Object. This only changes the type of the reference, leaving the actual data unchanged.

:: Casting an object from a base class to the actual class or one of the inherited classes on the way, for an example casting an Object reference that points to an actual HtmlButton object from Object to HtmlControl.

:: Boxing a value type into a reference type, for an example casting an int to an Object. This will allocate memory on the heap where an object structure containing the int is stored, and the result is an Object reference that points to that memory structure.

:: Unboxing a reference type to its value type, for an example casting from an Object to an int. This will retrieve the data from the memory structure and release the memory used on the heap. Unboxing can only be done to the exact value type that the object contains, no other value type.

---
b { font-weight: normal; }

QuestionParsing MS Word text Pin
emran83428-Jan-06 14:44
emran83428-Jan-06 14:44 
AnswerRe: Parsing MS Word text Pin
tarasn28-Jan-06 22:09
tarasn28-Jan-06 22:09 
GeneralRe: Parsing MS Word text Pin
emran83429-Jan-06 4:20
emran83429-Jan-06 4:20 
QuestionByte array + hex Pin
ita_cas28-Jan-06 8:25
ita_cas28-Jan-06 8:25 
QuestionUserControl Tutorial Pin
MarkMokris28-Jan-06 6:07
MarkMokris28-Jan-06 6:07 
AnswerRe: UserControl Tutorial Pin
Ravi Bhavnani28-Jan-06 16:54
professionalRavi Bhavnani28-Jan-06 16:54 
QuestionHow can I check if a mail exists or not? Pin
m.rastgar28-Jan-06 5:49
m.rastgar28-Jan-06 5:49 
AnswerRe: How can I check if a mail exists or not? Pin
Guffa28-Jan-06 12:02
Guffa28-Jan-06 12:02 
AnswerRe: How can I check if a mail exists or not? Pin
tarasn29-Jan-06 21:09
tarasn29-Jan-06 21:09 
AnswerRe: How can I check if a mail exists or not? Pin
Ista30-Jan-06 2:47
Ista30-Jan-06 2:47 
QuestionDefining nested namespace Pin
Ravi Bhavnani28-Jan-06 5:12
professionalRavi Bhavnani28-Jan-06 5:12 
AnswerRe: Defining nested namespace Pin
Guffa28-Jan-06 5:36
Guffa28-Jan-06 5:36 
GeneralRe: Defining nested namespace Pin
Ravi Bhavnani28-Jan-06 5:58
professionalRavi Bhavnani28-Jan-06 5:58 
Questionnewbie: do you ever define a class within a class ( Class A { Class B {} })? Pin
LuluSailor28-Jan-06 5:11
LuluSailor28-Jan-06 5:11 
AnswerRe: newbie: do you ever define a class within a class ( Class A { Class B {} })? Pin
Colin Angus Mackay28-Jan-06 5:48
Colin Angus Mackay28-Jan-06 5:48 
GeneralRe: newbie: do you ever define a class within a class ( Class A { Class B {} })? Pin
LuluSailor28-Jan-06 6:21
LuluSailor28-Jan-06 6:21 
AnswerRe: newbie: do you ever define a class within a class ( Class A { Class B {} })? Pin
Curtis Schlak.28-Jan-06 7:38
Curtis Schlak.28-Jan-06 7:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.