You are seeing a limited-style version of this site. Please upgrade your browser to view the site as it was meant. You can try Firefox, Google Chrome, or even Safari.

Brandon Martinez

Posts Tagged ‘C#’

 

Sanitizing Phone Numbers With C#

Posted in: Technology | , , ,

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.

 
 
 

C# Interfaces: Under (No) Construction?

Posted in: Technology | , ,

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
    //....
  }
}

Continue Reading…

 
 
 

XMLUrlResolver: Using Embedded XSLT Resources in C#

Posted in: Technology | , , ,

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:

Continue Reading…

 
 
 

What I’ve Learned So Far

Posted in: Technology | , , ,

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.

Continue Reading…

 
 
 

My First Week at Independent Printing

Posted in: Work | , ,

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.
Continue Reading…