Had a similar problem where I wanted to add methods to a string property.
My solution looks a little like this.
Create a new class like so:
public class MyString
{
public bool IsRequired()
{
// do some stuff
return true;
}
private string m_val;
// new property to accept string
public string Value
{
get{return m_val;}
set{m_val = value;}
}
// implicit conversion operator
public static implicit operator MyString(string str)
{
MyString myStr = new MyString();
myStr.Value = str;
return myStr;
}
}
And here's some code showing it's use.
MyString name = new MyString;
name = "Scott"
name.IsRequired();
string FullName = name.Value + "B";
Hope that helps...
--Scott
"Phill" <wa********@yahoo.com> wrote in message
news:ac**************************@posting.google.c om...
Why can't we add new methods to String or StringBuilder?