Return a string based on Type, Color and Position I recently wrote a really long one-liner, it was really just for fun, but I would like to know if it's bad practice or not. Can you tell me?

Here's my full class, but it's about the ToString() method.

namespace HGroupBadge.Classes
{
    public class BadgeDetail : BadgePart
    {
        public DetailType Type { get; set; }

        public BadgeDetail(DetailType type, BadgeColor color, BadgePosition position)
        {
            Type = type;
            Color = color;
            Position = position;
        }

        public override string ToString() 
            =&gt; ((int)Type &gt; 99 ? "t" : "s") 
            + ((int)Type &gt; 99 ? ((int)Type).ToString().Remove(0, 1) : ((int)Type &lt; 10 ? "0" + (int)Type : "" + (int)Type)) 
            + ((int)Color &lt; 10 ? "0" + (int)Color : "" + (int)Color) 
            + (int)Position;
    }
}


It has to return a string similar to s01137, when Type or Color are lower than 10, a leading 0 has to be added because the final string always has to end in 5 digits.  When Type is bigger than 99, the first digit has to be cut off. In the end, Position has to simply be added to the string.

DetailType, BadgeColor and BadgePosition are enums.
public override string ToString() 
    =&gt; ((int)Type &gt; 99 ? "t" : "s") 
    + ((int)Type &gt; 99 ? ((int)Type).ToString().Remove(0, 1) : ((int)Type &lt; 10 ? "0" + (int)Type : "" + (int)Type)) 
    + ((int)Color &lt; 10 ? "0" + (int)Color : "" + (int)Color) 
    + (int)Position;



You definitely should split it in a exactly four methods/variables:

Method 1: GetPrefix

((int)Type &gt; 99 ? "t" : "s")


Method 2: FormatSomething, sorry, I don't know what.

((int)Type &gt; 99 ? ((int)Type).ToString().Remove(0, 1) : ((int)Type &lt; 10 ? "0" +  (int)Type : "" + (int)Type)) 


Method 3: FormatColor:

((int)Color &lt; 10 ? "0" + (int)Color : "" + (int)Color)


Method 4: FormatPosition - this might be unnecessary but because all other formattings are method let's make this consistant.

(int)Position


Finally your ToString would look like this:

public override ToString() =&gt; 
    $"{GetPrefix()}{FormatSomething()}{FormatColor()}{FormatPosition()}"


and nobody asks any more questions about what your method is doing.