我必须存储一些基于状态代码的模板。我不能将它们存储在数据库中。所以我想创建一个以statecode为key,list为value的字典。我选择了一个列表,因为我需要一个line.So模板行,列表中的每个字符串都是一行。有没有更好的方法来处理这种情况。请发表意见。
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»"}}
};发布于 2010-01-18 18:28:21
第一种选择:您可以使用简单的字符串而不是列表,并使用Environment.NewLine ("\n")分隔单独的行。您可以使用StringBuilder对象轻松地创建这样的字符串,并使用string.Split()方法再次拆分它(如果需要)。这也比List<string>方法(稍微)快一些。
第二种选择:您可以使用文件,并且只将文件名存储在字典中。
以上选项中的一种是否是您原始方法的更好替代方案,取决于您正在处理的具体项目。总而言之,List<string>方法可能还不错……
哈!
发布于 2010-01-18 19:13:55
另一种选择是使用资源文件(通常用于本地化)。资源文件为存储文本或其他类型的对象提供了一个位置,这些对象可在网站、WPF或Windows窗体应用程序中使用,从而创建了一个用于维护文本的中心位置。使用资源文件还可以简化应用程序的维护。
https://stackoverflow.com/questions/2085046
复制相似问题