Software Development Archives - Digital Tool Factory blog

The Digital Tool Factory Blog

How to make a random name generator in C#

I recnetly came up with a simple random name generator to do an initial seed of a database for testing using real names,a nd I thought I would share. Here is my NameGenerator.cs file. It’s fairly simple, it just picks a name at random out of the top 100 first names and the top 100 last names for the year 2011. Enjoy!

The code for the random name generator in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyNamespace
{
public class NameGenerator
{
public static Random rnd = new Random();

 

public static string GenRandomLastName()
{
List<string> lst = new List<string>();
string str = string.Empty;
lst.Add(“Smith”);
lst.Add(“Johnson”);
lst.Add(“Williams”);
lst.Add(“Jones”);
lst.Add(“Brown”);
lst.Add(“Davis”);
lst.Add(“Miller”);
lst.Add(“Wilson”);
lst.Add(“Moore”);
lst.Add(“Taylor”);
lst.Add(“Anderson”);
lst.Add(“Thomas”);
lst.Add(“Jackson”);
lst.Add(“White”);
lst.Add(“Harris”);
lst.Add(“Martin”);
lst.Add(“Thompson”);
lst.Add(“Garcia”);
lst.Add(“Martinez”);
lst.Add(“Robinson”);
lst.Add(“Clark”);
lst.Add(“Rodriguez”);
lst.Add(“Lewis”);
lst.Add(“Lee”);
lst.Add(“Walker”);
lst.Add(“Hall”);
lst.Add(“Allen”);
lst.Add(“Young”);
lst.Add(“Hernandez”);
lst.Add(“King”);
lst.Add(“Wright”);
lst.Add(“Lopez”);
lst.Add(“Hill”);
lst.Add(“Scott”);
lst.Add(“Green”);
lst.Add(“Adams”);
lst.Add(“Baker”);
lst.Add(“Gonzalez”);
lst.Add(“Nelson”);
lst.Add(“Carter”);
lst.Add(“Mitchell”);
lst.Add(“Perez”);
lst.Add(“Roberts”);
lst.Add(“Turner”);
lst.Add(“Phillips”);
lst.Add(“Campbell”);
lst.Add(“Parker”);
lst.Add(“Evans”);
lst.Add(“Edwards”);
lst.Add(“Collins”);
lst.Add(“Stewart”);
lst.Add(“Sanchez”);
lst.Add(“Morris”);
lst.Add(“Rogers”);
lst.Add(“Reed”);
lst.Add(“Cook”);
lst.Add(“Morgan”);
lst.Add(“Bell”);
lst.Add(“Murphy”);
lst.Add(“Bailey”);
lst.Add(“Rivera”);
lst.Add(“Cooper”);
lst.Add(“Richardson”);
lst.Add(“Cox”);
lst.Add(“Howard”);
lst.Add(“Ward”);
lst.Add(“Torres”);
lst.Add(“Peterson”);
lst.Add(“Gray”);
lst.Add(“Ramirez”);
lst.Add(“James”);
lst.Add(“Watson”);
lst.Add(“Brooks”);
lst.Add(“Kelly”);
lst.Add(“Sanders”);
lst.Add(“Price”);
lst.Add(“Bennett”);
lst.Add(“Wood”);
lst.Add(“Barnes”);
lst.Add(“Ross”);
lst.Add(“Henderson”);
lst.Add(“Coleman”);
lst.Add(“Jenkins”);
lst.Add(“Perry”);
lst.Add(“Powell”);
lst.Add(“Long”);
lst.Add(“Patterson”);
lst.Add(“Hughes”);
lst.Add(“Flores”);
lst.Add(“Washington”);
lst.Add(“Butler”);
lst.Add(“Simmons”);
lst.Add(“Foster”);
lst.Add(“Gonzales”);
lst.Add(“Bryant”);
lst.Add(“Alexander”);
lst.Add(“Russell”);
lst.Add(“Griffin”);
lst.Add(“Diaz”);
lst.Add(“Hayes”);

str = lst.OrderBy(xx => rnd.Next()).First();
return str;
}
public static string GenRandomFirstName()
{
List<string> lst = new List<string>();
string str = string.Empty;
lst.Add(“Aiden”);
lst.Add(“Jackson”);
lst.Add(“Mason”);
lst.Add(“Liam”);
lst.Add(“Jacob”);
lst.Add(“Jayden”);
lst.Add(“Ethan”);
lst.Add(“Noah”);
lst.Add(“Lucas”);
lst.Add(“Logan”);
lst.Add(“Caleb”);
lst.Add(“Caden”);
lst.Add(“Jack”);
lst.Add(“Ryan”);
lst.Add(“Connor”);
lst.Add(“Michael”);
lst.Add(“Elijah”);
lst.Add(“Brayden”);
lst.Add(“Benjamin”);
lst.Add(“Nicholas”);
lst.Add(“Alexander”);
lst.Add(“William”);
lst.Add(“Matthew”);
lst.Add(“James”);
lst.Add(“Landon”);
lst.Add(“Nathan”);
lst.Add(“Dylan”);
lst.Add(“Evan”);
lst.Add(“Luke”);
lst.Add(“Andrew”);
lst.Add(“Gabriel”);
lst.Add(“Gavin”);
lst.Add(“Joshua”);
lst.Add(“Owen”);
lst.Add(“Daniel”);
lst.Add(“Carter”);
lst.Add(“Tyler”);
lst.Add(“Cameron”);
lst.Add(“Christian”);
lst.Add(“Wyatt”);
lst.Add(“Henry”);
lst.Add(“Eli”);
lst.Add(“Joseph”);
lst.Add(“Max”);
lst.Add(“Isaac”);
lst.Add(“Samuel”);
lst.Add(“Anthony”);
lst.Add(“Grayson”);
lst.Add(“Zachary”);
lst.Add(“David”);
lst.Add(“Christopher”);
lst.Add(“John”);
lst.Add(“Isaiah”);
lst.Add(“Levi”);
lst.Add(“Jonathan”);
lst.Add(“Oliver”);
lst.Add(“Chase”);
lst.Add(“Cooper”);
lst.Add(“Tristan”);
lst.Add(“Colton”);
lst.Add(“Austin”);
lst.Add(“Colin”);
lst.Add(“Charlie”);
lst.Add(“Dominic”);
lst.Add(“Parker”);
lst.Add(“Hunter”);
lst.Add(“Thomas”);
lst.Add(“Alex”);
lst.Add(“Ian”);
lst.Add(“Jordan”);
lst.Add(“Cole”);
lst.Add(“Julian”);
lst.Add(“Aaron”);
lst.Add(“Carson”);
lst.Add(“Miles”);
lst.Add(“Blake”);
lst.Add(“Brody”);
lst.Add(“Adam”);
lst.Add(“Sebastian”);
lst.Add(“Adrian”);
lst.Add(“Nolan”);
lst.Add(“Sean”);
lst.Add(“Riley”);
lst.Add(“Bentley”);
lst.Add(“Xavier”);
lst.Add(“Hayden”);
lst.Add(“Jeremiah”);
lst.Add(“Jason”);
lst.Add(“Jake”);
lst.Add(“Asher”);
lst.Add(“Micah”);
lst.Add(“Jace”);
lst.Add(“Brandon”);
lst.Add(“Josiah”);
lst.Add(“Hudson”);
lst.Add(“Nathaniel”);
lst.Add(“Bryson”);
lst.Add(“Ryder”);
lst.Add(“Justin”);
lst.Add(“Bryce”);

//—————female

lst.Add(“Sophia”);
lst.Add(“Emma”);
lst.Add(“Isabella”);
lst.Add(“Olivia”);
lst.Add(“Ava”);
lst.Add(“Lily”);
lst.Add(“Chloe”);
lst.Add(“Madison”);
lst.Add(“Emily”);
lst.Add(“Abigail”);
lst.Add(“Addison”);
lst.Add(“Mia”);
lst.Add(“Madelyn”);
lst.Add(“Ella”);
lst.Add(“Hailey”);
lst.Add(“Kaylee”);
lst.Add(“Avery”);
lst.Add(“Kaitlyn”);
lst.Add(“Riley”);
lst.Add(“Aubrey”);
lst.Add(“Brooklyn”);
lst.Add(“Peyton”);
lst.Add(“Layla”);
lst.Add(“Hannah”);
lst.Add(“Charlotte”);
lst.Add(“Bella”);
lst.Add(“Natalie”);
lst.Add(“Sarah”);
lst.Add(“Grace”);
lst.Add(“Amelia”);
lst.Add(“Kylie”);
lst.Add(“Arianna”);
lst.Add(“Anna”);
lst.Add(“Elizabeth”);
lst.Add(“Sophie”);
lst.Add(“Claire”);
lst.Add(“Lila”);
lst.Add(“Aaliyah”);
lst.Add(“Gabriella”);
lst.Add(“Elise”);
lst.Add(“Lillian”);
lst.Add(“Samantha”);
lst.Add(“Makayla”);
lst.Add(“Audrey”);
lst.Add(“Alyssa”);
lst.Add(“Ellie”);
lst.Add(“Alexis”);
lst.Add(“Isabelle”);
lst.Add(“Savannah”);
lst.Add(“Evelyn”);
lst.Add(“Leah”);
lst.Add(“Keira”);
lst.Add(“Allison”);
lst.Add(“Maya”);
lst.Add(“Lucy”);
lst.Add(“Sydney”);
lst.Add(“Taylor”);
lst.Add(“Molly”);
lst.Add(“Lauren”);
lst.Add(“Harper”);
lst.Add(“Scarlett”);
lst.Add(“Brianna”);
lst.Add(“Victoria”);
lst.Add(“Liliana”);
lst.Add(“Aria”);
lst.Add(“Kayla”);
lst.Add(“Annabelle”);
lst.Add(“Gianna”);
lst.Add(“Kennedy”);
lst.Add(“Stella”);
lst.Add(“Reagan”);
lst.Add(“Julia”);
lst.Add(“Bailey”);
lst.Add(“Alexandra”);
lst.Add(“Jordyn”);
lst.Add(“Nora”);
lst.Add(“Carolin”);
lst.Add(“Mackenzie”);
lst.Add(“Jasmine”);
lst.Add(“Jocelyn”);
lst.Add(“Kendall”);
lst.Add(“Morgan”);
lst.Add(“Nevaeh”);
lst.Add(“Maria”);
lst.Add(“Eva”);
lst.Add(“Juliana”);
lst.Add(“Abby”);
lst.Add(“Alexa”);
lst.Add(“Summer”);
lst.Add(“Brooke”);
lst.Add(“Penelope”);
lst.Add(“Violet”);
lst.Add(“Kate”);
lst.Add(“Hadley”);
lst.Add(“Ashlyn”);
lst.Add(“Sadie”);
lst.Add(“Paige”);
lst.Add(“Katherine”);
lst.Add(“Sienna”);
lst.Add(“Piper”);

str = lst.OrderBy(xx => rnd.Next()).First();
return str;
}
}
}


23
Apr 12


Written By Steve French

 

How to fix a missing reference to mscorlib in Visual Studio 2010

Runtime compiling is greatI was trying to update my main app code to utilize the .Net Framework 4.0 and this happened:

The Problem: I could find no obvious way to update the mscorlib reference in my solution, so I decide to simply delete it and add it again, and hope that it magically updates to the most recent version.  This is actually what usually happens with Visual Studio.  However, I delete the mscorlib reference, and I am unable to add it back again, I get the error message telling me that mscorlib is already included in the project.

The Cause: This is a known problem in Visual Studio.

The Solution: I just went into my project (.csproj) file and added the following line

<Reference Include=”mscorlib” />

And that fixed it.  I still have no idea how to make it use the most recent .Net Framework though.

Creative Commons License photo credit: dasapfe

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


26
Jul 10


Written By Steve French

 

Adventures with PayPal Website Payments Pro and Authorize.net

walletSeveral days ago I decided to use PayPal’s Website Payments Pro system for the Stronico credit card processing system.  At the time, I thought PayPal was the obvious choice.  It had relatively low fees (about $60 per month), no setup fee, and it seemed to be the 800 pound gorilla in the space, so how bad coudl it behard could the setup be?

As it turned out, I was very, very wrong.   I spent part of the day Sunday and all day Monday wading through non-working sample code, looking at near duplicate setup guides for the 56 (how it is 56 I don’t know) versions of their Website Payments Pro system, installing all of the add-ons needed to get the sample apps going and so on and so forth.  All of that merely to make a Get request with the proper query string (which is all the Website Payments Pro System really is). Continue reading →


09
Jun 10


Written By Steve French

 

The civil war between designers and developers shifts to developers

07 Battle of Tunnel Hill 034I’ve long viewed web development as a shifting balance of power between graphic designers and software developers.   A rough timeline would go something like this Continue reading →


27
Apr 10


Written By Steve French

 

Non-Disclosure Agreements are the Kiss of Death


nda
Creative Commons License photo credit: mil8

“Before I tell you about it you have to sign this!” is what they all say.  The idea will be written out over five pages, usually in the passive voice, with as many adjectives and adverbs as possible.  By the time you finish reading the document the concept will be fuzzier than when you started reading the document.

As a solo web/software I’ve signed 15 or so non-disclosure agreements (NDAs) over my past eight years in business for new products and companies.  I don’t recall any of the products being successful in the long term.  In fact, I can’t recall any of the products being around after six months.  Most of the products never reached any sort of development at all.  To a man the people pitching the NDAs had great enthusiasm, and  they all insisted on a great many meetings.  Why is this? Continue reading →


29
Jan 10


Written By Steve French

 

How to fix the Microsoft.Web.Administration.dll problem

The Problem: While coding away on the Stronico signup process I came across a problem with creating a reference to the Microsoft.Web.Administration dll, namely it was not present as a reference.  No problem, I added the dll manually via Visual Studio (it is in the %WinDir%System32InetSrv directory), yet once that was done I could not reference the dll.

The Cause: The dll must be marked as “Copy Local – True” and “Specific Version – True”.

The Solution: Mark the two options as true in the properties and the problem will go away.  It’s always the stupid errors that cause the most problems.  One of the purposes of blogging these errors is to  reduce their frequency.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


24
Jan 10


Written By Steve French

 

Quick review of RescueTime

Yesterday I downloaded and installed RescueTime – So far I like it. It hasn’t had that much time to gather data but it does identify many weak ponts. A longer review will be coming as soon as there is more to work with.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


03
Dec 09


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.