Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Product Key

Posted on November 17, 2014October 26, 2015 By David Kittell

This function can be used for various tasks but I happen to use it to make product keys cleaner or easier to read.

public static string sProductKey(string sRawText, int nLength)
        {
            string sFinal = "";
            for (int i = 0; i <= sRawText.Length; i += nLength)
                {
                    if (i + nLength < sRawText.Length)
                        {
                            sFinal += sRawText.Substring(i, nLength) + "-";
                        }
                    else
                        {
                            sFinal += sRawText.Substring(i);
                        }
                }
           return sFinal;
        }
Console.WriteLine(sProductKey("ABCDEFGHIJKLMNOPQRSTUVWXY", 5));

Before: ABCDEFGHIJKLMNOPQRSTUVWXY
After: ABCDE-FGHIJ-KLMNO-PQRST-UVWXY

Originally Posted on November 17, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp

Post navigation

Previous post
Next post

Related Posts

Page View Details

Posted on July 9, 2013October 26, 2015

DISCLAIMER: Before you put this script in place make sure you have some kind of disclaimer on your site to state what kind of data you record from the visitor. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[pageview] ( [id] [int] IDENTITY(1, 1)…

Read More

Azure CLI – Download All Blobs

Posted on September 15, 2017

If you ever need to get your files out of Azure this script will help you get your files out of Blob Storage azBlob="<blob name>" azContainer="<container name>" azStorageKey="<primary or secondary storage key>" fpDestination="$HOME/Desktop/$azBlob/$azContainer" # Change this to a path you want mkdir -p $fpDestination echo "Listing the blobs from $sContainer…"…

Read More

ICD-9 Generator

Posted on August 21, 2014October 26, 2015

<%@ Page Language="C#"%> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Collections.Generic" %> <%@ Import Namespace="System.Collections.Specialized" %> <%@ Import Namespace="System.Configuration" %> <%@ Import Namespace="System.Data.Common" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Printing" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Net.Mail" %> <%@ Import Namespace="System.Text" %> <%@ Import Namespace="System.Text.RegularExpressions"…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes