26.04.2012, 03:00
|
#32
|
.
Регистрация: 05.08.2006
Сообщений: 10,429
Написано 3,454 полезных сообщений (для 6,863 пользователей)
|
Ответ: Какая запись кодового блока вам милее?
Сообщение от radiobutton
switch (t_v)
{
case 1:
case 2:
{
int a=string_part(s,1,"-1234567890",0);
if (a!=s.Length)
{
if (s.Substring(a,1)==",")
{
if (a+1<=s.Length)
{
if (string_part(s,a+1,"1234567890",0)==s.Length)
{
if (t_v==1)
{return Convert.ToInt32(Convert.ToDouble(s)).ToString();}
else
{return s;}
}
else
{
MessageBox.Show("Incorrect value of object.");
}
}
else
{
MessageBox.Show("Incorrect value of object.");
}
}
else
{
MessageBox.Show("Incorrect value of object.");
}
}
else
{
return s;
}
}break;
case 3:
{
if (s.Substring(0,1)=="'" && s.Substring(s.Length-1)=="'")
{
return s;
}
else
{
MessageBox.Show("Incorrect value of object.");
}
}break;
default:
{MessageBox.Show("WTF??");}break;
}
|
Фи как никрасиво..
Я бы вот так оформил:
switch (t_v) {
case 1:
case 2:
{
int a=string_part(s,1,"-1234567890",0);
if (a!=s.Length) {
if (s.Substring(a,1)==",") {
if (a+1<=s.Length) {
if (string_part(s,a+1,"1234567890",0)==s.Length) {
if (t_v==1) {
return Convert.ToInt32(Convert.ToDouble(s)).ToString();
} else {
return s;
}
} else {
MessageBox.Show("Incorrect value of object.");
}
} else {
MessageBox.Show("Incorrect value of object.");
}
} else {
MessageBox.Show("Incorrect value of object.");
}
} else {
return s;
}
break;
}
case 3:
{
if (s.Substring(0,1)=="'" && s.Substring(s.Length-1)=="'") {
return s;
} else {
MessageBox.Show("Incorrect value of object.");
}
break;
}
default:
{
MessageBox.Show("WTF??");
break;
}
}
|
(Offline)
|
|