using  in generic delegates? Here is my problem.  Do I need to give a new identifier to each delegate I write of the following delegate type? like so: or could i use one delegate that accounts for any Datatype I need to use so i don't have to keep repeating the code?

Something that may or may not be relevant: I'm calling these functions to prompt user's input for new fields to add for records in a database.  So database field types are the data types I'm dealing with, but I'm using this approach for learning purposes to try and minimize redundancy.

public static class stcHelper  // helper class
{
    public delegate T DelReturnType&lt;T&gt;();
    static public DelReturnType&lt;int&gt; UserInt = () =&gt;
    {
        Console.Write("Enter integer: ");
        return int.Parse(Console.ReadLine());
    };
    static public DelReturnType&lt;string&gt; UserString = () =&gt;
    {
        Console.Write("Enter string: ");
        return Console.ReadLine();
    };
    static public DelReturnType&lt;AnotherDataType&gt; UserAnotherDataType = () =&gt;
    {
        Console.Write("Enter AnotherDataType: ");
        return SomeKindOfConversionFunction(Console.ReadLine());
    };
    // and so on for what could be 15 other data types ..
}


or is there a better way to reduce redundant code?

The code below is also part of the same class.

public static class stcHelper
{
    static public T InsistValidInput&lt;T&gt;(DelTypeReturn&lt;T&gt; MyInputAction)
    {
        bool bSuccess = true;
        do
        {
            try
            {
                return MyInputAction();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Invalid input!" + ex.ToString());
                bSuccess = false;
            }
        } while (!bSuccess);
        return default(T);
    }
}
If done cleverly, you can get away with a single method to get the input of any type:

static T GetInput&lt;T&gt;(string message, Converter&lt;string, T&gt; transform)
{
    Console.WriteLine(message);
    return transform(Console.ReadLine());
}


All you need to do is pass in a transformation function (the Converter&lt;TInput,TOutput&gt; delegate is equivalent to Func&lt;T,TResult&gt;):

int parsedInt = GetInput("Type in a number", int.Parse);
float parsedFloat = GetInput("Type in a float", float.Parse);


And ta-da, you've got your input, parsed as the desired type.

But as you also noted in the second half of your question, it's dangerous to assume that the input will always be valid. There's a universal version of your insist-on-valid-input function too. However, you should avoid using exceptions for normal control flow. Use the xxx.TryParse methods instead.

First, define the following delegate that matches the TryParse method defined in all the primitive types:

delegate bool TryParse&lt;T&gt;(string input, out T output);


Then, you can implement the loop:

static T InsistOnValidInput&lt;T&gt;(string message, string errorMessage, TryParse&lt;T&gt; validator)
{
    Console.WriteLine(message);
    T result;
    while (!validator(Console.ReadLine(), out result))
    {
        Console.WriteLine(errorMessage);
    }
    return result;
}


And call it:

bool parsedBool = InsistOnValidInput&lt;bool&gt;("Type in a bool", "Try again", bool.TryParse);


Unfortunately, C# doesn't infer the type parameter of the output argument, so you need to specify it manually (in this case, &lt;bool&gt;).