❔ 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
It is fixed, i didn't know about find and replace
fyi there is no difference between
var Xape = new Country
and Country Xape = new Country
you can tell chatgpt to use explicit types instead of var next time
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.