I know I am deviating away from what you've specifically asked for, but, why must the customer object name be the customer's name? Why can't the customer's name be one of the variables within the customer object?
Code:
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication5
{
class Program
{
static List<Customer> customers;
static void Main()
{
// let's say these are the names in a string array
String[] names = new String[] { "david", "john", "peter", "andrew", "simon" };
// why not have a list of Customer objects and include
// the customer's name within the Customer object
customers = new List<Customer>();
// initial population of the list
foreach (String str in names)
customers.Add(new Customer(str));
// example of finding a customer's object
Customer test = GetCustomer("david");
if (test == null)
Console.WriteLine("customer doesn't exist.");
else
Console.WriteLine("customer exists!! :-)");
}
static Customer GetCustomer(String CustomerName)
{
var query = from x in customers where x.CustomerName == CustomerName select x;
if (query.Count<Customer>() > 0)
return query.ToArray<Customer>()[0];
return null;
}
}
class Customer
{
public String CustomerName;
// adding the rest of your object variables and methods here
public Customer(String CustomerName)
{
this.CustomerName = CustomerName;
}
public override bool Equals(object obj)
{
// give the Equals method a proper purpose
return this.CustomerName == ((Customer)obj).CustomerName;
}
public override int GetHashCode() { return base.GetHashCode(); }
}
}