Rather than having class1 take in the variable count, why not create three classes with a common base class?
public abstract class Class1Base
{
protected class1(int count) { }
}
public class Class1Count4
{
public Class1Count4()
: base(4)
{ }
}
// also have implementations for the other eligible values for count.
If your algorithm actually changes based off of what count is (i.e. there is no common code between the separate usages of count), then you can use an interface instead:
public interface IClass1
{
// Interface methods
}
public class CountImpl4 : IClass1
{
// Implement IClass1 with count being 4.
}
// Other implementations.
With either of these designs you then take the possibility of invalid user input out of the equation. Plus, if you ever need to change how one implementation works, need to support other count values, etc. you can just extend Class1Base / implement IClass1 with another class.
Edit
Since you wish to keep this within one class, why not define Type-Safe enumeration to pass in?
public struct CountEnum
{
public readonly int Count;
public static readonly CountEnum Four = new CountEnum(4);
public static readonly CountEnum Six = new CountEnum(6);
public static readonly CountEnum Eight = new CountEnum(8);
private CountEnum(int count)
{
Count = count;
}
}
public class Class1
{
public Class1(CountEnum countEnum)
{
// Access the value via countEnum.Count.
}
}
Since CountEnum only has a single private constructor, the only available instances are the statically-defined Four, Six, and Eight. The user can now only enter Four, Six, or Eight. Since CountEnum is a struct, null is not available either.