Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Is StringBuilder class Value type?

Reply
 
Old 07-18-2008   #1 (permalink)
sameem


 
 

Is StringBuilder class Value type?

Thanks a lot.

"Frans Bouma [C# MVP]" wrote:
Quote:

> sameem wrote:
Quote:

> > Dear All
> >
> > up to my level that I have known the StringBuilder class is reference type.
> > Someone telling that StringBuilder class is Value type.
> >
> > Hence I want to clarify which is right? and how?
>
> It's a reference type. String is also a reference type (though it
> behaves like a valuetype). To determine if a type is a valuetype or a
> reference type, you can look into the MSDN, lookup the type's
> documentation page, and you can see if it inherits from a class (except
> when it inherits from System.ValueType) or it is a class itself ->
> reference type, if it is a struct (e.g. Int32) or if it inherits from
> System.ValueType, it is a value type. A struct automatically inherits
> from System.ValueType, see reflector on System.Int32 for example.
>
> In general, a type which is mutable is likely to be a reference type,
> or at least should be a reference type, according to MS guidelines.
>
> So first thing to check: documentation.
>
> FB
>
> --
> ------------------------------------------------------------------------
> Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
> LLBLGen Pro website: http://www.llblgen.com
> My .NET blog: http://weblogs.asp.net/fbouma
> Microsoft MVP (C#)
> ------------------------------------------------------------------------
>

My System SpecsSystem Spec
Old 07-18-2008   #2 (permalink)
Frans Bouma [C# MVP]


 
 

Re: Is StringBuilder class Value type?

sameem wrote:
Quote:

> Dear All
>
> up to my level that I have known the StringBuilder class is reference type.
> Someone telling that StringBuilder class is Value type.
>
> Hence I want to clarify which is right? and how?
It's a reference type. String is also a reference type (though it
behaves like a valuetype). To determine if a type is a valuetype or a
reference type, you can look into the MSDN, lookup the type's
documentation page, and you can see if it inherits from a class (except
when it inherits from System.ValueType) or it is a class itself ->
reference type, if it is a struct (e.g. Int32) or if it inherits from
System.ValueType, it is a value type. A struct automatically inherits
from System.ValueType, see reflector on System.Int32 for example.

In general, a type which is mutable is likely to be a reference type,
or at least should be a reference type, according to MS guidelines.

So first thing to check: documentation.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
My System SpecsSystem Spec
Old 07-18-2008   #3 (permalink)
sameem


 
 

Re: Is StringBuilder class Value type?

Thanks a lot.

"Frans Bouma [C# MVP]" wrote:
Quote:

> sameem wrote:
Quote:

> > Dear All
> >
> > up to my level that I have known the StringBuilder class is reference type.
> > Someone telling that StringBuilder class is Value type.
> >
> > Hence I want to clarify which is right? and how?
>
> It's a reference type. String is also a reference type (though it
> behaves like a valuetype). To determine if a type is a valuetype or a
> reference type, you can look into the MSDN, lookup the type's
> documentation page, and you can see if it inherits from a class (except
> when it inherits from System.ValueType) or it is a class itself ->
> reference type, if it is a struct (e.g. Int32) or if it inherits from
> System.ValueType, it is a value type. A struct automatically inherits
> from System.ValueType, see reflector on System.Int32 for example.
>
> In general, a type which is mutable is likely to be a reference type,
> or at least should be a reference type, according to MS guidelines.
>
> So first thing to check: documentation.
>
> FB
>
> --
> ------------------------------------------------------------------------
> Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
> LLBLGen Pro website: http://www.llblgen.com
> My .NET blog: http://weblogs.asp.net/fbouma
> Microsoft MVP (C#)
> ------------------------------------------------------------------------
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
When a class is both an inherited class of another, and alsoimplements an interface method .NET General
win32_pingstatus class / dns class PowerShell
Generic Class: Passing Data Type to Placeholder .NET General
Re: Unable to cast COM object of type 'ADODB.RecordsetClass' to class type 'System.Object[]' .NET General
Unable to find type [Drawing.Image]: make sure that the assembly containing this type is loaded PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46