473,407 Members | 2,629 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.

Alternative to inheriting from string

Hello,

I would like to write a string-like class that will only allow certain
string values, (for example, specified with a regular expression). I'd
still like it to behave like a string, I just don't want to ensure the
validity of it's value. Since you can't inherit from string, what would be
the best way to approach this?

Mike
Nov 22 '05 #1
2 1701
What about creating a class who's only property is a string? THen on the
set access modifier you can run your regex and validation routine against it
and ensure that's what you want. You could also make it an indexed property
and only let it have one value so you cna make it the default property
"Mike" <no**@none.com> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
Hello,

I would like to write a string-like class that will only allow certain
string values, (for example, specified with a regular expression). I'd
still like it to behave like a string, I just don't want to ensure the
validity of it's value. Since you can't inherit from string, what would be the best way to approach this?

Mike

Nov 22 '05 #2
Thanks William,

I don't quite understand your comment about indexed properties. Could you
please elaborate?

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
What about creating a class who's only property is a string? THen on the
set access modifier you can run your regex and validation routine against it and ensure that's what you want. You could also make it an indexed property and only let it have one value so you cna make it the default property
"Mike" <no**@none.com> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
Hello,

I would like to write a string-like class that will only allow certain
string values, (for example, specified with a regular expression). I'd
still like it to behave like a string, I just don't want to ensure the
validity of it's value. Since you can't inherit from string, what would

be
the best way to approach this?

Mike


Nov 22 '05 #3

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

Similar topics

3
by: Mike | last post by:
Hello, I would like to write a string-like class that will only allow certain string values, (for example, specified with a regular expression). I'd still like it to behave like a string, I...
62
by: christopher diggins | last post by:
Since nobody responded to my earlier post , I thought I would try to explain what I am doing a bit differently. When multiply inheriting pure virtual (abstract) base classes, a class obviously...
11
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain...
3
by: vidalsasoon | last post by:
I have a class "SomeForm" that inherits a "Global" class which in turn inherits "System.Windows.Forms.Form". As you may have guessed all my other classes that are inheriting from "Global" are also...
10
by: Andrew McLellan | last post by:
I think I must be missing something about generics, perhaps just about the syntax. I'd like to derive a class MyList from System.Collections.Generic so that it can only contain instance of MyItem....
3
by: Roy Soltoff | last post by:
Two books, "Mastering Visual Basic.Net" and "Visual Basic.Net Developer's Handbook" describe inheriting from System.EventArgs using a class similar to: Public Class MyEventArgs Inherits...
10
by: cbdeja | last post by:
I am using a "unsigned long long" as a label to identify various transactions that are taking place in my program. The label is reserved during the lifetime of the transaction and then released...
24
by: toton | last post by:
Hi, I want to have a vector like class with some additional functionality (cosmetic one). So can I inherit a vector class to add the addition function like, CorresVector : public...
1
by: UptownYardy | last post by:
Hi excuse the mistake in the title. I'm having trouble on inheriting methods from a superclass in Java. Basically I've forgotten how to. I want to inherit 3 methods from the Artwork superclass to...
4
by: MisterPete | last post by:
I created an object that inherits from file and was a bit surprised to find that print seems to bypass the write method for objects inheriting from file. An optimization I suppose. Does this...
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.