M
Mike
WARNING: newbie to C#
Is there a way to do this:
WCHAR szString[] = L"This is your girlfriends string";
LPWSTR pszString = szString; // This is a pointer to her string
wcscpy(pszString, L"And now I touch it!");
in C#?
Something like this:
string strText = "This is C# string";
object objText = strText; // I want this to be a pointer to that string
objText = "But this doesn't change strText";
but then working please! ;o)
From the description in MSDN strText.Clone() looked promising, but no...
Reason I want to do this is prevent having to duplicate "Leave"
eventcode for every textbox on my form:
this.txtCompany.Text = customerClass.Company.Name;
this.txtCompany.Tag = customerClass.Company.Name;
this.txtCompany.Leave += new EventHandler(txtOnLostFocus);
this.txtCompanyAddress.Text = customerClass.Company.Address;
this.txtCompanyAddress.Tag = customerClass.Company.Address;
this.txtCompanyAddress.Leave += new EventHandler(txtOnLostFocus);
private void txtOnLostFocus(object sender, EventArgs e)
{
TextBox txt = (TextBox)sender;
if (txt.Tag.ToString() != txt.Text)
txt.Tag = txt.Text;
// In the case of a Leave event on txtCompany,
// customerClass.Company.Name should change
// In the case of a Leave event on txtCompanyAddress,
// customerClass.Company.Address should change
}
I understand there is probably a better way to achieve what I want but
I'm too new to C# to think of it...
Thanks guys/girls!
Is there a way to do this:
WCHAR szString[] = L"This is your girlfriends string";
LPWSTR pszString = szString; // This is a pointer to her string
wcscpy(pszString, L"And now I touch it!");
in C#?
Something like this:
string strText = "This is C# string";
object objText = strText; // I want this to be a pointer to that string
objText = "But this doesn't change strText";
but then working please! ;o)
From the description in MSDN strText.Clone() looked promising, but no...
Reason I want to do this is prevent having to duplicate "Leave"
eventcode for every textbox on my form:
this.txtCompany.Text = customerClass.Company.Name;
this.txtCompany.Tag = customerClass.Company.Name;
this.txtCompany.Leave += new EventHandler(txtOnLostFocus);
this.txtCompanyAddress.Text = customerClass.Company.Address;
this.txtCompanyAddress.Tag = customerClass.Company.Address;
this.txtCompanyAddress.Leave += new EventHandler(txtOnLostFocus);
private void txtOnLostFocus(object sender, EventArgs e)
{
TextBox txt = (TextBox)sender;
if (txt.Tag.ToString() != txt.Text)
txt.Tag = txt.Text;
// In the case of a Leave event on txtCompany,
// customerClass.Company.Name should change
// In the case of a Leave event on txtCompanyAddress,
// customerClass.Company.Address should change
}
I understand there is probably a better way to achieve what I want but
I'm too new to C# to think of it...
Thanks guys/girls!