Re: Classes, Properties, and structures

From: David Browne (meat_at_hotmail.com)
Date: 10/24/04


Date: Sun, 24 Oct 2004 15:52:59 -0500


"OpticTygre" <optictygre@adelphia.net> wrote in message
news:RLSdne5E0e-hieHcRVn-iQ@adelphia.com...
> Interesting point. I suppose also, that since it is a class, there is
> also the ability to add function, subroutines, events and such that apply
> specifically to an object of type "Person" whereas you wouldn't be able to
> do something like that with a simple structure.

You can add methods, properties, etc to a structure. The distinction
between a Class and a Structure is that a class is created on the heap, and
a structure is a ValueType created on the stack.

A ValueType which contains only ValueType's for fields will be created
entirely on the stack and won't generate any garbage.

David



Relevant Pages

  • Re: Help me with redback and unibasic
    ... That problem is as old as subroutines. ... You need to keep track of the stack ... XLr8 the tool for RedBack ... need to abort from one of those subroutines and get back to ASP. ...
    (comp.databases.pick)
  • Re: No machine stack and C
    ... sensitive computing souls...whence the stack, ... Taylorism created the infamous "lines of code ... inimical to "Taylorists" because a tree structure of subroutines ...
    (comp.lang.c)
  • Re: Paper on PL/I
    ... a hardware stack for subroutine calling and returning. ... Turing and his team developed software (subroutines) for a variety of tasks ... stack machines of the Burroughs line and of the English Electric KDF9, ... recognizing his occupation, complaints about languages (Algol, FORTRAN, ...
    (comp.lang.pl1)
  • Re: Structure C# internals
    ... from value types" rule remains intact. ... This is making bit confusion. ... System.ValueType is getting allocated in stack? ... Basically the CLR knows that types derived from ValueType are value ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why cant I inherit from DateTime?
    ... > a Intel 32-bit register as a ValueType with methods and operators. ... an System.Int32 is NOT a ValueType. ... it's a 32-bit in register or on a stack. ... What value type semantics does Int32 *not* exhibit? ...
    (microsoft.public.dotnet.languages.csharp)

Loading