Is everything an object?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

In VB .NET everything is supposed to be an object. Say I have a report
title hard coded in a method. When a method is called, is the returned
title an object or a string?

Thanks,
Brett
 
Brett said:
In VB .NET everything is supposed to be an object. Say I have a report
title hard coded in a method. When a method is called, is the returned
title an object or a string?

It's a string object.
 
Herfried K. Wagner said:
It's a string object.

What exactly does that mean? What is the difference between a string and a
string object?

The string returned has no properties, methods and cannot be instantiated.
Why would it be considered an object?

Thanks,
Brett
 
Brett said:
What exactly does that mean? What is the difference between a string and
a string object?

The string returned has no properties, methods and cannot be instantiated.
Why would it be considered an object?

The string returned by a method that returns a string actually has methods,
and 'String' inherits from 'Object', which is the common base class of all
types (notice that this does not apply to interfaces because interfaces
cannot be instantiated).

\\\
Dim s As String = Foo(...)
MsgBox(s.ToLower())
///
 
Did you not notice such methods as "Split", "EndsWith and "StartsWith"?

Everything in .NET is an object. Even basic types such as integers and
singles are derived from Object. This is why they have the .ToString method
for example.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Brett,

In addition to the others, you can use a "default" return type for every
object

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top