1,字符是否为空,2,比较两个字符大小。String.Compare(String, String)。string.IsNullOrEmpty(string)

2023-06-20,,

1,

String.Compare 方法 (String, String)

比较两个指定的 String 对象。

条件

小于零

strA 小于 strB。

strA 等于 strB。

大于零

strA 大于 strB。

实例:

if (string.Compare(beginDate.ToString("yyyyMMdd"), endDate.ToString("yyyyMMdd")) > )
{
throw new GSPException("开始日期不能大于结束日期", ErrorLevel.Info);
}

String.IsNullOrEmpty 方法 (String)

指示指定的字符串是 null 还是 Empty 字符串。

返回值

Type: System.Boolean

如果 true 参数为 value 或空字符串 (""),则为 null;否则为 false

实例:

if (string.IsNullOrEmpty(ds.Tables["RebatePolicy"].Rows[]["RebateGuid"].ToString()))
throw new GSPException("不是制单状态,不允许删除", ErrorLevel.Info);

1,字符是否为空,2,比较两个字符大小。String.Compare(String, String)。string.IsNullOrEmpty(string)的相关教程结束。

《1,字符是否为空,2,比较两个字符大小。String.Compare(String, String)。string.IsNullOrEmpty(string).doc》

下载本文的Word格式文档,以方便收藏与打印。