473,385 Members | 2,162 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,385 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 1149
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.