C# 3.0 在c中使用字典存储模板#

C# 3.0 在c中使用字典存储模板#,c#-3.0,C# 3.0,我必须根据statecode存储一些模板。我无法将它们存储在数据库中。所以我想创建一个字典,statecode作为键,list作为值。我选择了一个列表,因为我需要一行一行的模板。所以列表中的每个字符串都是一行。有没有更好的办法来处理这种情况。请评论 private static readonly Dictionary<string, List<string>> NotaryForStates = new Dictionary<string, List<stri

我必须根据statecode存储一些模板。我无法将它们存储在数据库中。所以我想创建一个字典,statecode作为键,list作为值。我选择了一个列表,因为我需要一行一行的模板。所以列表中的每个字符串都是一行。有没有更好的办法来处理这种情况。请评论

private static readonly Dictionary<string, List<string>> NotaryForStates = new Dictionary<string, List<string>>()
    {
        {"AR",new List<string> {"Per Steve Hollowell, ESQ from the Legal Division of the AR, SOS. Telephone number for the Legal Division of the SOS: (501)-682-3012. Arkansas Code 16-47-101.", "State of Arkansas", "County of <notary county>","On this day, <sign date> before me, <name of notary>, the undersigned notary, personally appeared, <name of signer> who acknowledged he/she is the <title of signer> of <name of company> and that he/she as such <title of signer>, being authorized so to do, executed the foregoing instrument for the purposes therein contained, by signing the name of the corporation by himself/herself as <title of signer>.","In witness whereof I hereunto set my hand and official seal.","______________________","Notary Public","<Notary name>","My Commission expires: <notary commission date>"}},
        {"CA",new List<string>{"State of California","County of <Notary County>","On <sign date> before me, <Notary Name>, Notary Public, personally appeared <Signing Party Name>, who proved to me on the basis of satisfactory evidence to be the person(s) whose name is subscribed to the within instrument and acknowledged to me that he/she executed the same in his/her authorized capacity, and that by his/her signature on the instrument the person, or the entity upon behalf of which the person acted, executed the instrument.","I certify under PENALTY OF PERJURY under the laws of the State of California that the foregoing paragraph is true and correct.","WITNESS my hand and official seal.","______________________________","Notary Public: «NotaryName»","My Comm. Expires: «NotaryCommExp»"}},
        {"FL",new List<string>{"State of Florida","County of <Notary County>","On <sign date> before me, the undersigned, a Notary Public, for said County and State, personally appeared  <Signing Party Name>,  personally known to me to be the person that executed the foregoing instrument and acknowledged that is a <signer title> of <name of company>  and that he/she did execute the foregoing instrument.   <Name of Signer> is personally known to me.","_____________________","Notary Public: «NotaryName»","My Comm. Expires: «NotaryCommExp»"}}
    };
private static readonly Dictionary NotaryForStates=new Dictionary()
{
{“AR”,新名单{“Per Steve Hollowell,SOS AR法律部ESQ.SOS法律部电话号码:(501)-682-3012.阿肯色州代码16-47-101.,“阿肯色州”,“阿肯色州”,“在这一天,在我面前,签字的公证人亲自出庭,他/她承认他/她是的,并且他/她本人被授权这样做,为其中所载的目的,签署了上述文书,签署了公司的名称,作为。”本人特此签名并加盖公章,以资证明,
{“CA”,新名单{“加利福尼亚州”、“加利福尼亚县”、“在我面前,公证人亲自出庭,并根据令人满意的证据向我证明此人其姓名在文书内签署,并向本人确认,他/她以其授权身份签署了该文书,并通过其在文书上的签名,该人或其代表的实体签署了该文书。”根据加利福尼亚州的法律,本人根据伪证罪证明上述条款真实无误。”、“见证我的签名和公章。”、“公证人:«公证人姓名»、«公证人»我的委托书到期:«公证人»,
{“FL”,新名单{“佛罗里达州”,“佛罗里达州”,“纽约州”,“在我面前,签署人,一名公证人,代表上述州和州,亲自出现,我个人知道他是签署上述文书的人,并承认他/她是签署上述文书的人。我个人知道。”_____________________“,“公证人:«公证人姓名»”,“我的通信到期:«公证人通信»”}”
};

第一种选择:您可以使用简单字符串而不是列表,并使用
Environment.NewLine
(“\n”)分隔单独的行。您可以使用
StringBuilder
对象轻松创建此类字符串,然后使用
string.split()
方法再次拆分(如果需要)。这也是(稍微)比
列表
方法更快

第二种选择:您可以使用文件并在字典中只存储文件名

以上选项之一是否比您原来的方法更好,取决于您正在从事的具体项目。总之,
列表
方法可能还可以


HTH!

另一种选择是使用资源文件(通常用于本地化).资源文件提供了一个位置,用于存储可在网站、WPF或Windows窗体应用程序中使用的文本或其他类型的对象,从而创建一个用于维护文本的中心位置。使用资源文件还可以简化应用程序的维护。

@Rohit您还可以从文件中选择模板。其优点是如果模板有小的变化,您不需要更新代码。