如何在xml文件中设置长度?

时间:2018-09-09 18:49:18

标签: c#

我需要将ContractId字段的长度设置为最大25。我怎样才能做到这一点? 以其他方式可以使用子字符串,如何使用我尝试使用的子字符串,但是它可以查找字段何时有值,但是当字段没有值时会抛出错误,所以我想知道如何使用子字符串而不会导致此错误。

                       new XElement(ns + "projectInfo",
                           new XElement(ns + "awardingBody", string.Empty),
                           new XElement(ns + "contractAgencyID", String.Empty),
                           new XElement(ns + "contractAgency", IsLcpCertified ? (certStatusRecord.ContractorProject.IsSub == true ? 
                                              certStatusRecord.ContractorProject.PrimeContractorName : certStatusRecord.ContractorProject.AwardingAgency) :
                                              certStatusRecord.ContractorProject.PrimeContractorId == null ? accountName : certStatusRecord.ContractorProject.PrimeContractor.Name),
                           new XElement(ns + "projectName", ""),
                           new XElement(ns + "projectID", certStatusRecord.Project.DIRProjectId),
                           new XElement(ns + "awardingBodyID", ""),
                           new XElement(ns + "projectNum", ""),
                           new XElement(ns + "contractID", **certStatusRecord.ContractorProject.ContractId**),
                           new XElement(ns + "projectLocation",
                               new XElement(ns + "description", ""),
                               new XElement(ns + "street", ""),
                               new XElement(ns + "city", ""),
                               new XElement(ns + "county", ""),
                               new XElement(ns + "state", ""),
                               new XElement(ns + "zip", ""))),
                       new XElement(ns + "payrollInfo",
                           new XElement(ns + "statementOfNP", certStatusRecord.Performing == "YES" ? false : true),

0 个答案:

没有答案