Is there any significant difference between using if/else and switch-case in C#?

前端 未结 20 1220
时光取名叫无心
时光取名叫无心 2020-11-22 07:25

What is the benefit/downside to using a switch statement vs. an if/else in C#. I can\'t imagine there being that big of a difference, other than m

20条回答
  •  鱼传尺愫
    2020-11-22 07:37

    I Think Switch Is More Faster Than If Conditions like see if There is a program like :

    Write a Program to enter any number (between 1 – 99) and check it is in which slot a) 1 – 9 then slot one b) 11 – 19 then slot two c) 21-29 then slot three and so on till 89-99

    Then On If You Have Have To Make Many Conditions But Son Switch Case You Have TO Just Type

    Switch ( no /10 )

    and on case 0 = 1-9 ,case 1 = 11-19 and so on

    it will Be So Easy

    There Are Many More Such Examples Also!

提交回复
热议问题