C
C#2y ago
Odin

❔ Is there a way to quickly change all instances of "var" in my code to "Country"?

I had ChatGPT do some stuff and it named everything var and I have a Country method, I need to convert every instance of var to Country over, let me check, 3500 lines of code. //bad code var Xape = new Country { Name = "Xape", ArmySize = 1831, MaxArmySize = 2266, Industry = 145, MaxIndustry = 951, Manpower = 633, MaxManpower = 5397, TotalTerritory = 41, AvailableTerritory = 6, Territories = new List<Territory> { new Territory { Name = "Xapia", IsOccupied = False }, new Territory { Name = "Xapan", IsOccupied = False }, } }; //good code Country Dudu = new Country { Name = "Dudu", ArmySize = 1617, MaxArmySize = 2002, Industry = 404, MaxIndustry = 800, Manpower = 836, MaxManpower = 7878, TotalTerritory = 36, AvailableTerritory = 34, Territories = new List<Territory> { new Territory { Name = "Dudor", IsOccupied = False }, new Territory { Name = "Dudis", IsOccupied = False }, new Territory { Name = "Dudia", IsOccupied = False }, } };
4 Replies
Odin
OdinOP2y ago
It is fixed, i didn't know about find and replace
Thinker
Thinker2y ago
fyi there is no difference between var Xape = new Country and Country Xape = new Country
Denis
Denis2y ago
you can tell chatgpt to use explicit types instead of var next time
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server