Hi,
I am new to C# and trying to do some testing.
I created a Class Library and compiled it to a DLL. The DLL replaces unwanted characters from a Telephone number. e.g. When a user enters a telephone number (+1(123)-456-7890) in a textbox and on event onTextBox_TextChange() the telephone number gets cleaned to 11234567890.
The code below is from the Class Library:
The Code that will use the DLL:
The question i'd like to ask is when I instantiate the Telephone object, all the properties and methods are exposed and I can use them.
But when I try accessing the "Telephone." object directly, it only shows 2 methods (Equals and ReferenceEquals). I'd like to expose all the methofs and properties without instantiating the Telephone objects. Can this be done? How?
Please help.
Thanks
Neld
I am new to C# and trying to do some testing.
I created a Class Library and compiled it to a DLL. The DLL replaces unwanted characters from a Telephone number. e.g. When a user enters a telephone number (+1(123)-456-7890) in a textbox and on event onTextBox_TextChange() the telephone number gets cleaned to 11234567890.
The code below is from the Class Library:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Windows.Forms;
namespace Common.DLL
{
public class Telephone
{
public string FormattedAsIs { get; set; }
private string m_Telephone = string.Empty;
public string Formatted
{
get { return m_Telephone; }
set
{
m_Telephone = CleanTelephone(value);
}
}
public string CleanTelephone(string StrValue)
{
string pattern = @"[^\d]";
string replacement = string.Empty;
Regex rgx = new Regex(pattern);
StrValue = rgx.Replace(StrValue, replacement);
return StrValue;
}
}
}
The Code that will use the DLL:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Common.DLL;
namespace Practice
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//The telephone functionalities...
//When instantiating the Telephone Object the Properties and Methods are exposed.
//*******************************************************************************
Telephone T = new Telephone();
T.FormattedAsIs = "12345";
T.Formatted = "a9b8c7654#3@2!1";
MessageBox.Show (T.FormattedAsIs + ' ' + '*' + ' ' + T.Formatted);
//When accessing the Telephone Object the Properties and Methods are not exposed except equals and referenceequals.
//*****************************************************************************************************************
Telephone.
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
The question i'd like to ask is when I instantiate the Telephone object, all the properties and methods are exposed and I can use them.
But when I try accessing the "Telephone." object directly, it only shows 2 methods (Equals and ReferenceEquals). I'd like to expose all the methofs and properties without instantiating the Telephone objects. Can this be done? How?
Please help.
Thanks
Neld