472,805 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 1138
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.