Posts Tagged ‘C#’
An extension method to remove all but digits from a phone number. This should be useful for sanitizing input to put into your database.
using System.Text.RegularExpressions;
namespace CustomStringMethods
{
public static class PhoneNumber
{
#region Class Methods
public static string StripAllButDigits(this string s)
{
return (s == null) ? string.Empty : Regex.Replace(s, @"\D", string.Empty);
}
#endregion
}
}Obviously this can be used for more than just phone numbers.
Why can’t C# allow for a constructor definition in an Interface? For example, say you have this interface:
namespace ValidationServices.Customers
{
public interface ICustomer
{
// Properties
ValidationRequest Request{ get; set;}
// Methods
ValidationResponse ValidateOrder();
//....
// and so on
//....
}
} Read more…
Over the last week or so, I have been searching for a method to properly include XSL files via xsl:include within a .NET embedded resource. Apparently, using GetManifestResourceStream() (via an Assembly) wasn’t good enough (it wouldn’t follow the xsl:includes, simply ignoring them). Luckily, I came across a (semi-)working solution over at Signs on the Sand. Now, the concepts behind this were right, it just wasn’t working for my particular situation. Here’s the scoop:
Read more…
So far, my internship has been going great! I’ve had many opportunities to work in a new environment, and I’ve been able to tap into one of my more underused skills: programming. Since I’ve been working for Independent, I’ve been able to learn a lot of new concepts; not only in programming, but in some of the operations of a business. Here is a brief overview of some of the things I have learned, or am learning.
Read more…
Let me start off by saying: this past week was incredible! It’s hard to think of where to start; there are so many things that happened! Check out the rest of the post to see how things went.
Read more…