Links
 
Welcome to myCodeShare
The goal of this site is:
  • » To provide a place where users can post some useful sample code and coding tips
  • » To allow users to provide feedback and improvement suggestions for code snippets
  • » To build a community, where like minded developers, can find answers to questions
Other great development sites:
Latest Updates

Title Casing a String in .NET using C#

.NET
C#
REGEX
When researching different ways of title casing a string in .NET using C# I came across two methods other than my own custom solution. Using Regular Expressions: This method looks...

Using Interlocked.Exchange to make a Thread Safe Variable Replacement

.NET
C#
When trying to replace static variables in a class, I always used a static object for doing a lock() before the update.public class SomeClass { private static readonly object theLock...

Setting up Multiple Web Sites with IIS on Windows XP

ASP.NET
XP's limitation of allowing only one Virtual IIS Server has always been somewhat of a hurdle when doing .NET development on XP. I recently found a workaround for this...

ASP.NET: How to Prevent Browser Page Caching and Successfully Expire Content

ASP.NET
Page and Cache expiration on IIS is sometimes not completely obvious. One common problem is that certain browsers (in our case IE), seem to be more prone than others, to...

MSSQL: Stripping a DATETIME Value of its Time Value

MSSQL
Stripping a DATETIME value of its time element has been the one thing in SQL that I've had to do at every job. Yet I always forget how to...

Access a Private Static Member of a another Class using C# (.NET)

C#
.NET
This method allows access to a private static member variable of any class. I've used this primarily in NUnit tests, where I wanted to check on hidden details, that...

Convert a String of Integers to a List of Integers using C# and LINQ

C#
LINQ
LAMBDA
This C# code snippet takes a comma delimited string of integers, and converts in to a List<int> variable. It uses LINQ to perform the conversion from List...

HTTP 301 Redirect using C# / ASP.net

ASP.NET
C#
Why a 301 Redirect vs. Response.Redirect? A 301 redirect is a way to tell visitors and search engines, that a page has moved to a new location permanently. Response...

Stripping HTML tags using Regular Expressions (RegEx) in C#

C#
HTML
REGEX
Quick method for removing HTML tags from a string, and making it safe for being inside of an attribute. Using a combination of RegEx and a StringBuilder.var builder = new...

Binary Serialization to and from Memory Variables in C#

C#
.NET
Binary serialization come sometimes come in handy, when an alternative to XML Serialization is needed. Serialize to Byte Array:public static byte[] BinarySerialize(object Source) { var for...

Query XML fields in MSSQL using TSQL and XQuery. Getting Counts and Values.

MSSQL
XML
Finding the number of occurrences of an element in XML. This query returns the number of occurences of the title element under an article element from the MyTable.XmlField column...

Export to CSV from the ASP.NET using C#

ASP.NET
C#
Here is some sample code for outputting some CSV content from the web to a browser, as a downloadable CSV file.var delimitedOutput = 'test,me,now' Response.Clear(); Response.ClearHeaders...

MSSQL: Get only the Date part from a DATETIME value

MSSQL
Here is something that I constantly have to use, and always have a hard time finding. From what I understand, this is the fastest way in TSQL (2005) to strip...

Adding a CSS stylesheet to a UserControl

CSS
ASP.NET
User Controls can have their own CSS stylesheets, which can get added to the Page's <HEAD> element when the control is loaded. In order to do this...

Wildcard SELECT with a LIKE clause, using the '_' character

MSSQL
I ran into a problem recently trying to find usernames that contained the '_' character. So having forgotten some of my more in depth SQL skills, I wrote the following query...
Contact Us | Terms of Use