Re: String Reference Type



no heap is used.

the variable x is on the stack and is the value, rather than reference to the value. the variable MyValue being a class static value, is allocated in the static class definition structure, and again is the value, not a pointer to the value.

in .net numerics, bools, dates, structures and enums are value types, everything else is a true object and thus a reference type.

-- bruce (sqlwork.com)


RN1 wrote:
On Feb 10, 4:38 am, "Jonathan Wood" <jw...@xxxxxxxxxxxxxxxx> wrote:
Lars,

No, Strings in Pascal (and ADA as I reacll) are tru types.
This appears to be to me but I don't know what "no" refers to, or what "tru
types" are.

I could be wrong but it seems to me you are confusing terms. I'm not that
familiar with Delphi but a reference in C++ is different from a .NET
reference type. I don't know the exact criteria used to determine value or
reference type, but to me a reference type is a pointer, and so any type
that requires a pointer seems it would be a good candidate. And as far as
I'm concerned, all strings require pointers, whether they are made available
to the language that uses them or not. (Certainly, it wouldn't make sense to
ever store a string in a register or even on the stack.)

Don't know about C# but I hope the compiler takes care of this. By
references or not is not of interest. What is of interest is if you have
the option to use call by value for strings or if all parameters are
treated as references. Can you use call by value in C# how do you use call
by value?
According tohttp://www.knowdotnet.com/articles/referencetypes2.html, "One
of the most common mistakes developers make when learning .NET is confusing
Reference and Value Types with Passing values by Reference or Value." Again,
I think you are confusing terms.

--
Jonathan Wood
SoftCircuits Programminghttp://www.softcircuits.com

OK...now suppose I have the following code:

<script runat="server">
Class MyInt
Public MyValue As Integer
End Class

Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim x As New MyInt

...................
...................
...................
End Sub
</script>

If I am not wrong, the Dim line in the Page_Load sub "creates space in
the heap & returns a pointer (say, 0x000001)". To whom does the Dim
line return the pointer?

Please correct me if I am wrong.
.



Relevant Pages

  • Re: ByVal vs. ByRef
    ... When you pass a reference type byval: ... A copy of the passed *pointer* to the reference is made. ... So, if you pass an object ByVal, you're passing that "pointer" ByVal, so ...
    (microsoft.public.dotnet.languages.vb)
  • Re: String Reference Type
    ... pointer to the value. ... lblClassName name to "My String". ... everything else is a true object and thus a reference type. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: String Reference Type
    ... pointer to the value. ... lblClassName name to "My String". ... everything else is a true object and thus a reference type. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Newbie Question
    ... to make my own picture of the difference of value and reference types. ... This adress which points on the stack can ... If a new instance of a reference type is generated then the same ... is an adresse which points to the heap where the real data of the ...
    (microsoft.public.vb.general.discussion)
  • Newbie Question about Value and Reference Types
    ... to make my own picture of the difference of value and reference types. ... This adress which points on the stack can ... If a new instance of a reference type is generated then the same ... is an adresse which points to the heap where the real data of the ...
    (microsoft.public.dotnet.languages.vb)

Loading