473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Class design ToString

rc
is there anyway of creating a class so that when it is used as the object
directly it does the toSting implementation
ie
public class recordID
private mid as string
public overloads function Tostring as string
retrun mid
end function
end class
so if i was using recorid anywhere then i dont get unable to convert to
string error
Jul 21 '05 #1
3 1152
What you want is not available in VB.NET for VS2003, you need to overload the
"+" operation and the Cast operation which will be available in VS2005.

"rc" wrote:
is there anyway of creating a class so that when it is used as the object
directly it does the toSting implementation
ie
public class recordID
private mid as string
public overloads function Tostring as string
retrun mid
end function
end class
so if i was using recorid anywhere then i dont get unable to convert to
string error

Jul 21 '05 #2
On Fri, 15 Apr 2005 10:04:02 -0700, "Jorge Matos"
<matos_jorge(NOSPAM)@hotmail.com> wrote:

You mean you can't do this in VB.NET?:

public override string ToString()
{
return TheStringYouWantToReturn;
}
What you want is not available in VB.NET for VS2003, you need to overload the
"+" operation and the Cast operation which will be available in VS2005.

"rc" wrote:
is there anyway of creating a class so that when it is used as the object
directly it does the toSting implementation
ie
public class recordID
private mid as string
public overloads function Tostring as string
retrun mid
end function
end class
so if i was using recorid anywhere then i dont get unable to convert to
string error


Otis Mukinfus
http://www.otismukinfus.com
Jul 21 '05 #3
Otis,

Overriding methods is different from overloading operators, you can override
methods in VB.NET if you mark the method as Overrideable, but you cannot
override an operator such as "+" or "-", at least not until VS2005 is
released. Please refer to the following article for more info:

http://msdn.microsoft.com/library/de...ml/vs03h12.asp

"Otis Mukinfus" wrote:
On Fri, 15 Apr 2005 10:04:02 -0700, "Jorge Matos"
<matos_jorge(NOSPAM)@hotmail.com> wrote:

You mean you can't do this in VB.NET?:

public override string ToString()
{
return TheStringYouWantToReturn;
}
What you want is not available in VB.NET for VS2003, you need to overload the
"+" operation and the Cast operation which will be available in VS2005.

"rc" wrote:
is there anyway of creating a class so that when it is used as the object
directly it does the toSting implementation
ie
public class recordID
private mid as string
public overloads function Tostring as string
retrun mid
end function
end class
so if i was using recorid anywhere then i dont get unable to convert to
string error


Otis Mukinfus
http://www.otismukinfus.com

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eric | last post by:
Using the 1.1 framework. We are using a newly created instance of a RichTextBox Class in our server code to manipulate RTF that is stored in the database. To clarify, we are not using or...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
3
by: Trammel | last post by:
Hi, I recently upgraded to VB.net from VB6.. and woah... I feel lost :¬O One of my reasons for upgrading is I was told that VB.net can do class inheritance and subclassing easier. ...
2
by: rc | last post by:
is there anyway of creating a class so that when it is used as the object directly it does the toSting implementation ie public class recordID private mid as string public overloads function...
0
by: Hans Koller | last post by:
Hello group, I design a class to bind it to a property grid for easy modification of some settings. My problem is now that I want to raise an event when a settings has been changed. Thats not a...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
9
by: raylopez99 | last post by:
Here are two different ways of achieving a mediator pattern: the first, using circular references (for lack of a better way to describe it), but not using delegates, with the second using...
1
by: DarkGiank | last post by:
Hi, im new to csharp and im trying to create a class that can change the application database without no rewriting all connection code... but cause some reason it is not working... it tells me that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.