def define_name(n):
    """
    Formats an all-uppercase version of the name for use in C# defines.
    @param n: The class name to format in define style.
    @type n: string
    @return The resulting valid C# define name
    @rtype: string
    """
    n2 = ''
    for i, c in enumerate(n):
        if ('A' <= c) and (c <= 'Z'):
            if i > 0:
                n2 += '_'
                n2 += c
            else:
                n2 += c
        elif (('a' <= c) and (c <= 'z')) or (('0' <= c) and (c <= '9')):
            n2 += c.upper()
        else:
            n2 += '_'
    return n2