配售数据库连接字符串中的.resx文件字符串、数据库连接、文件、resx

2023-09-04 02:31:14 作者:难离难舍想抱紧些

我们能发生在.resx文件数据库连接字符串在C#类库项目类型? 如果是这样, 有哪些优点和缺点?

Can we Place Database Connection Strings in .resx file in C# Class library project type?? If so, What are the advantages and disadvantages?

推荐答案

您可以把你想要的任何东西到的resx文件,并读回,不应该有这有什么问题。至于优势去,你没有得到任何好处,从它相比,把它变成你的应用程序配置文件。相反,在访问字符串变得更加繁琐,而且你不能在运行时改变它们。

You can put anything you want into a resx file and read it back, there should not be any problem with that. As far as advantages go, you do not get any advantage from it compared to putting it into your application config file. On the contrary, accessing the string becomes more cumbersome, and you cannot alter them at runtime.

一般来说,我看把连接串入的resx并编译成你的code与编译时间常数相差不大。

Generally speaking, I see little difference between putting the connection string into resx and compiling it into your code with a compile-time constant.

不用说,在他们的口令字符串应该不会进入配置或RESX文件为纯文本。

It goes without saying that strings with passwords in them should never go into config or resx files as plain text.