1

我正在尝试将以下语句重写为 ac# 语句,以便我可以在我的程序中使用 if。我对水晶报告公式的理解不足以将其重写。

If Not IsNull({RET_USER_INFORMATION.TX_PHONE_WORK}) And Length (ToText({RET_USER_INFORMATION.TX_PHONE_WORK},0,"")) > 1 Then "(" & Mid (ToText({RET_USER_INFORMATION.TX_PHONE_WORK},0,""), 1, 3) & ") " & Mid (ToText({RET_USER_INFORMATION.TX_PHONE_WORK},0,""), 4, 3) &" - "& Mid (ToText({RET_USER_INFORMATION.TX_PHONE_WORK},0,""), 7, 4) 否则 "";

4

1 回答 1

0
 string _foo = RET_USER_INFORMATION !=null && !String.IsNullOrEmpty(RET_USER_INFORMATION.TX_PHONE_WORK) ?  RET_USER_INFORMATION.TX_PHONE_WORK.ToString() : String.Empty;

 if(!String.IsNullOrEmpty(_foo))
 {
   return  String.Format("({0}){1}-{2}", _foo.Substring(0,3), _foo.Substring(3,3), _foo.Substring(6,4));
 }
 else
 {
   return String.Empty;
 }
于 2012-12-28T02:43:31.480 回答