【发布时间】:2015-07-21 20:34:25
【问题描述】:
private void CharsAvailable()
{
int num = 0;
int num2 = 0;
string text = this.txtMessage.Text;
if (this.chkSignature.Checked)
{
text = text + Environment.NewLine + this.txtSignature.Text;
}
else
{
text = this.txtMessage.Text;
}
int num3 = 0;
while (num != 1 && num3 < this.txtMessage.TextLength)
{
if (text[num3] < '0' || text[num3] > '9')
{
if (text[num3] < 'A' || text[num3] > 'Z')
{
}
..............................
SOME CODE
............................
if (num == 1)
{
int num4 = text.Length;
if (num4 <= 70)
{
num4 = 1;
}
else
{
num4 += 62;
num4 -= num4 % 63;
num4 /= 63;
}
frmCompose.isUnicodeFound = true;
this.lblChar.Text = string.Concat(new object[]
{
text.Length,
" characters, ",
num4,
" SMS message(s)"
});
}
else
{
int num4 = text.Length + num2;
if (num4 <= 160)
{
num4 = 1;
}
else
{
num4 += 152;
num4 -= num4 % 153;
num4 /= 153;
}
frmCompose.isUnicodeFound = false;
this.lblChar.Text = string.Concat(new object[]
{
text.Length + num2,
" characters, ",
num4,
" SMS message(s)"
});
}
}
//validation
if (this.txtMessage.Text.Trim().Length == 0)
{
MessageBox.Show("Blank messages cannot send. Please type the message.", "Blank Message");
}
else if (frmCompose.isUnicodeFound && this.cmbLanguage.SelectedIndex == 0)
{
MessageBox.Show("Please choose 'Unicode' in Language dropdown to send message(s) in non English.”", "Unicode Message");
}enter code here
我需要一些帮助来将此函数转换为 php 函数。 php代码中相关函数中的类似语法或类似函数是什么?任何人都可以提供帮助。如果我得到一些需要进行的更改列表,那就太好了。在此先感谢。
【问题讨论】:
-
所有 if 语句之母:D
-
什么鬼?!为什么 1000 次相同的条件?文本[num3] != '?'为什么不只增加和检查其他情况?
-
根据经验,任何超过 7 的嵌套都应该重构。
-
@Abhicenation,首先发布一个关于如何简化深层嵌套 if 语句的问题。
-
它并不复杂,它很糟糕。有更好的方法来检查字符是否有效。看看正则表达式什么的。