1
Answer

Is it possible to define an argument as Range?

Photo of minmin

minmin

16y
2.6k
1

Say I created a method void test (byte var) and the var only take a number in the Range(1, 3) only.

How can I define the "var" to make this possible?? 

Answers (1)

0
Photo of Scott Lysle
NA 28.5k 14.4m 16y

            private string Test(byte b)

            {

                  if (b >= 1 && b <= 3)

                  {

                        return "Good enough";

                  }

                  else

                  {

                        return "Out of range";

                  }

            }