Da_Gamer icon

Cleaned Name (Short 2)

Da_Gamer | PRO | 01/08/16 03:36:18 PM UTC | 0 ⭐ | 247 👁️ | Never ⏰ | []
C# |

930 B

|

None

|

0 👍

/

0 👎

    public class CleanedName
    {
        // Clean Name
        // --------------------------------------------------
        // Given a string, this will remove illegal characters so
        // it fits within Maya naming conventions
        public static string CleanName(string name)
        {
            // We have to strip out any illegal characters from the name
            // a-z A-Z 0-9 and _ are the only accepted characters
 
            StringBuilder cleanedName = new StringBuilder(name.Length);
 
            // We will be moving forward through the name,
            // keeping only letters, numbers, and underscores.
            foreach (char character in name)
            {
                if (char.IsLetterOrDigit(character) || character == '_') cleanedName.Append(character);
            }
 
 
            // Convert the stringbuilder into a string
            return cleanedName.ToString();
        }
    }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎