0

Let's say we have car management software and codes are,

if (power== "gasoline")
{
   // many code
}
else if (power== "diesel")
{
   // many code
}
else if (power== "electric")
{
   // many code 
}
else if (power== "hybrid")
{
   // many code
}

As title of this question, I don't want the code of 'diesel', 'electric', 'hybrid' to be loaded into memory to improve performance when a user selects 'gasoline'.

Is there a excellent way for this case ?

Thank you !

Kay Lee
  • 922
  • 1
  • 12
  • 40
  • 2
    Strangest one question. Which exact performance metric you want to improve? – PWND Mar 27 '21 at 13:51
  • @PWND, welcome any question. I can't understand what you mean exactly due to my poor english. I would just tell you the amount of codes which I don't want load into memory are 50,000 lines...That's why this question is important to me. – Kay Lee Mar 27 '21 at 14:01
  • 1
    i seriously doubt that there's any way to do this that will save you any kind of performance. – Franz Gleichmann Mar 27 '21 at 14:01
  • @KayLee your question is wrong. If you want load less C# code - it doesn't improve your performance. Try to improve the approach of programming, I mean use async programming and so on. – PWND Mar 27 '21 at 14:04
  • @PWND, I'm a self-learning programmer without IT background. Thanks for your kind advice. – Kay Lee Mar 28 '21 at 10:11
  • Put the `50k lines of code` chunks in different assemblies. Then load them on demand as demonstrated in [this answer](https://stackoverflow.com/a/465509/419761). However, I believe this will be costlier. Unless you have millions of lines :P – l33t Mar 31 '21 at 09:43
  • @l33t, many thanks for bringing good ideas to my small, trifling question. Because programming is not my working job, I hope I reach there in the future..:) – Kay Lee Apr 01 '21 at 14:01

0 Answers0