//一个return
namespace
CleanCSharp.Methods.Dirty { class MethodExitPoints { public string GenerateAgeAppropriateGreeting( int customerAgeInYears) { string greeting; if (customerAgeInYears < 16) { greeting = "Yo!"; } else if (customerAgeInYears < 25) { greeting = "Hi there"; } else { greeting = "Dear Sir/Madam"; } return greeting; } } }
//多个return
namespace
CleanCSharp.Methods.Clean { class MethodExitPoints { public string GenerateAgeAppropriateGreeting( int customerAgeInYears) { if (customerAgeInYears < 16) { return "Yo!"; } if (customerAgeInYears < 25) { return "Hi there"; } return "Dear Sir/Madam"; } } }

 

相关文章:

  • 2021-09-30
  • 2022-12-23
  • 2021-11-25
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案