Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将验证从免费pdf asp.net mvc(c#)转换为vb.net_C#_Asp.net Mvc_Vb.net - Fatal编程技术网

将验证从免费pdf asp.net mvc(c#)转换为vb.net

将验证从免费pdf asp.net mvc(c#)转换为vb.net,c#,asp.net-mvc,vb.net,C#,Asp.net Mvc,Vb.net,既然vb没有yield关键字,您将如何将此代码转换为vb.net 谢谢 public IEnumerable<RuleViolation> GetRuleViolations() { if (String.IsNullOrEmpty(Title)) yield return new RuleViolation("Title required", "Title"); if (String.IsNullOrEmpty(Description))

既然vb没有yield关键字,您将如何将此代码转换为vb.net

谢谢

public IEnumerable<RuleViolation> GetRuleViolations() {
    if (String.IsNullOrEmpty(Title))
        yield return new RuleViolation("Title required", "Title");
    if (String.IsNullOrEmpty(Description))
        yield return new RuleViolation("Description required","Description");
    if (String.IsNullOrEmpty(HostedBy))
        yield return new RuleViolation("HostedBy required", "HostedBy");
    if (String.IsNullOrEmpty(Address))
        yield return new RuleViolation("Address required", "Address");
    if (String.IsNullOrEmpty(Country))
        yield return new RuleViolation("Country required", "Country");
    if (String.IsNullOrEmpty(ContactPhone))
        yield return new RuleViolation("Phone# required", "ContactPhone");
    if (!PhoneValidator.IsValidNumber(ContactPhone, Country))
        yield return new RuleViolation("Phone# does not match country", "ContactPhone");
    yield break;
}
public IEnumerable GetRuleViolations(){
if(String.IsNullOrEmpty(Title))
退回新的违规行为(“需要标题”、“标题”);
if(String.IsNullOrEmpty(Description))
退回新的违规行为(“需要说明”、“说明”);
if(String.IsNullOrEmpty(HostedBy))
收益返回新规则违规(“要求托管比”、“托管比”);
if(String.IsNullOrEmpty(Address))
退回新的违规行为(“所需地址”、“地址”);
if(String.IsNullOrEmpty(国家))
收益返回新规则违反(“国家要求”、“国家”);
if(String.IsNullOrEmpty(ContactPhone))
返回新的违规行为(“电话”必填项、“联系电话”);
如果(!PhoneValidator.IsValidNumber(联系人电话,国家/地区))
返回新规则违规(“电话与国家/地区不匹配”、“联系电话”);
屈服断裂;
}

创建一个列表,只需将这些规则添加到列表中,而不是执行“收益回报”。然后只需返回列表。

创建一个列表,而不是执行“屈服返回”,只需将这些规则添加到列表中即可。然后只需返回列表。

这是可行的,但需要注意的是,它不会延迟执行——即,CPU必须先完成列表,然后再返回,而不是根据请求计算列表中的每个项目。这就是说,在VB.NET中没有“收益回报”的直接等价物,因此这是最快的选择。这是可行的,但需要注意的是,这不是延迟执行——即CPU必须在返回之前先完成列表,而不是按要求计算列表中的每个项目。这就是说,VB.NET中没有“收益率回报”的直接等价物,因此这是最快的选择。