我知道有像vb到c#轉換器應用程序那裏的東西,但我所尋找的是有點不同。我需要一個轉換器來幫助我將這個「for」循環轉換爲「while」循環。這裏是我爲「Integer Factory」設計的代碼(你可以看到底部的「for」循環 - 這是需要轉換的東西)。我還有其他幾個循環,這就是爲什麼我需要一個應用程序(最好是wysiwyg)。謝謝!for循環轉換器
int IntegerBuilderFactory(string stringtobeconvertedbythefactory)
{
string strtmp = stringtobeconvertedbythefactory;
int customvariabletocontrolthethrottling;
if (strtmp.Length > 0)
{
customvariabletocontrolthethrottling = 1;
}
else
{
customvariabletocontrolthethrottling = 0;
}
for (int integersforconversiontostrings = 0; integersforconversiontostrings < customvariabletocontrolthethrottling; integersforconversiontostrings++)
{
return int.Parse(strtmp);
}
try
{
return 0;
}
catch (Exception ex)
{
// Add logging later, once the "try" is working correctly
return 0;
}
}
你需要一個應用程序,重構「幾個for-loops」while循環?爲什麼你不能手動做? – 2013-02-19 13:32:04
爲什麼即使是一個for循環,如果它返回它轉換的第一個元素?你有沒有試圖以某種方式簡化代碼,或者你有這個實際的代碼? – R0MANARMY 2013-02-19 13:36:11
@ R0MANARMY,這是我過去幾天一直在努力的真實代碼。我正在簡化轉換流程。我使用循環來提高安全性和內存效率。我會開放給你可能有的任何建議! – 2013-02-19 13:50:28