谢LZ教诲
刚来报到
还没入行楼主指点指点我该看看什么书
怎么学习呀
学好怎么用呀


程序代码:public class Progam {
public static void Main(string[] args) {
while (true) {
string str = "";
int cou = 0;
long myLong = 0;
string newStr = "";
bool rightEnter = false;
do
{
Console.WriteLine("Please enter an integer:");
try
{
myLong = Convert.ToInt64(Console.ReadLine());
}
catch {
Console.WriteLine("Error ! Please re-enter!");
}
str = myLong.ToString();
str.ToArray();
if (str == "")
{
Console.WriteLine("Error !\nPlease re-enter!");
}
else
rightEnter = true;
} while (rightEnter==false);
for (int i = str.Length; i > 0; i--) {
++cou;
newStr += str[i-1];
if (cou == 3&&i>=2) {
if (str[i - 1] != '-'&&str[i-2]!='-')
{
newStr += ',';
cou = 0;
}
}
}
for (int i = newStr.Length; i > 0; i--) {
Console.Write(newStr[i-1]);
}
Console.WriteLine("\n");
}
}
}