如何将此声明分离到单独的文件中?
我有一个非常长的字符串(下面是reallyLongString),并且想将其声明/定义放在与主代码不同的文件中。 我该怎么做?谢谢。 我可以在另一个文件中用 "publicpartial class MainWindow: Window {" and "}"
包围它吗?
namespace MyApp
{
public partial class MainWindow : Window
{
string reallyLongString = "...";
...
}
...
}
I have a really long string (reallyLongString below) and want to put its declaration/definition in a separate file from the main code.
How do I do that? Thanks.
Can I just surround it with "public partial class MainWindow: Window {" and "}"
in another file?
namespace MyApp
{
public partial class MainWindow : Window
{
string reallyLongString = "...";
...
}
...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上是的,尽管我认为您只能指定子类型一次。因此,在一个文件中:
在另一个文件中:
您还可以查看 resx 或嵌入式资源,而不是文字。
Yes basically, although I think you can only specify the sub-type once. So in one file:
And in the other:
You could also look at a resx or an embedded resource, rather than a literal.