WPF 应用程序应该用 C++/CLI 还是 C# 编写?

发布于 2024-09-13 16:42:39 字数 276 浏览 1 评论 0原文

WPF 应用程序的核心是托管应用程序吗? 对吗? 因此,我必须在使用托管 C++ 或托管之间进行选择C#。几年前我尝试过托管 C++。似乎还没有为黄金时段做好准备。我猜微软在托管 C# 上投入的精力比托管 C++ 更多。因此,使用托管 C# 似乎是两者之间的最佳替代方案。是这样吗?您在使用这两种语言的 WPF 方面有哪些经验?提前致谢。

WPF applications are, at its core, managed applications? Right? So, I have to choose between using managed C++ or managed C#. I experimented with managed C++ years ago. It seemed to be not quite be ready for primetime. I'm guessing Microsoft has put more effort into managed C# than managed C++. So, it seems like using managed C# is the best alternative between the two. Is this the case? What experiences have you had with WPF in either language? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

素食主义者 2024-09-20 16:42:39

托管 C++ 已被 C++/CLI 取代,“托管 C#”就是 C#。

我强烈建议您在新项目中使用 C#,并仅在需要时使用 C++/CLI。 C# 拥有更好的支持,拥有更大的用户群,并且更容易在 Visual Studio 2010 中使用。

此外,请记住 C++ 和 C++/CLI 是两种不同的语言。对于我的第一个 .Net 项目,我选择了 C++/CLI,因为我已经了解 C++,这是一个非常糟糕的主意:从 C++ 到 C++/CLI 的学习曲线类似于从 C++ 学习 C#:不要陷入这个陷阱。

Managed C++ has been replaced by C++/CLI, and "managed C#" is just C#.

I would strongly recommend you to use C# for a new project, and use C++/CLI only when needed. C# has a better support, has a larger user base, and is easier to work with inside Visual Studio 2010.

Additionally, keep in mind that C++ and C++/CLI are two different languages. For my first .Net project, I chose C++/CLI because I already knew C++, and this was a very bad idea: the learning curve from C++ to C++/CLI is similar to learning C# from C++: don't fall into that trap.

放手` 2024-09-20 16:42:39

C++/CLI 的真正目的只是为了支持在非托管代码(即本机 C/C++)和托管代码之间编写互操作层。对于“繁重的工作”,您绝对应该使用 C#(或 VisualBasic.NET)。

C++/CLI was only really made to support writing interop layers between unmanaged code (i.e. native C/C++) and managed code. For "heavy lifting", you should definitely use C# (or VisualBasic.NET).

兮颜 2024-09-20 16:42:39

您可以将托管 C++ 用于后端,但经检查,VS(我使用的是 2010 Ultimate)没有任何用于 C++ WPF 应用程序的内置模板 - 只有 C# 或 VB。

我确信如果您愿意,您可以强制它工作,但我建议您使用 C#。

You can use managed C++ for your backend but, on inspection, VS (I'm using 2010 Ultimate) doesn't have any in-built templates for a C++ WPF application - only C# or VB.

I'm sure you could force it to work if you wanted to, but I'd suggest you use C#.

此刻的回忆 2024-09-20 16:42:39

C# 是最常用的,因此如果您遇到麻烦,可以查看更多对 C# 的在线支持。 C#也得到了微软更好的支持。总的来说,即使是现在,它也只是一个更成品。如果你真的不在乎自己,我会选择 C#。

C# is the most used, so if you have trouble, there is more online support for C#. C# also has better support by Microsoft. It's overall just a more finished product, even now. If you really don't care yourself, i'd go with C#.

离笑几人歌 2024-09-20 16:42:39

就后端而言,它们都运行在 CLR 上并且都能够胜任这项工作。实际上,这取决于您最舒服的方式。如果您不确定,请尝试两者。
使用任何感觉最有成效的东西。

编辑

正如刚才向我指出的那样,C++ 似乎不支持 WPF 模板(甚至可能是智能感知)。所以在这种情况下我想我必须推荐 C#。

In terms of the backend, they both run on the CLR and both capable of the job. Really it just comes down to what you're most comfortable with. If you're not sure, experiment with both.
Use whatever feels most productive.

Edit:

As has just been pointed out to me though, it seems support for WPF templates (and possibly even intellisense) just isn't there for C++. So in that case I guess I'd have to recommend C#.

飘过的浮云 2024-09-20 16:42:39

IMO 毫无疑问是 C#(或 VB/F#)。

C++/CLI 在跨越托管世界和 C++ 库的边界时非常有用。尽管由于将托管语言和非托管语言相结合而产生了一些微妙的问题,但复杂性更高。

C++/CLI 中的编译时间也更长,特别是因为代码模板是根据 C# 编译器的工作方式建模的,而不是根据 C++ 编译器的工作方式建模的。

IMO without a doubt C# (or VB/F#).

C++/CLI is great when crossing the border of managed world and a c++ library. Complexity is higher though as subtle issues arises from the fact that one combine a managed language and an unmanaged.

Compile times are longer though as well in C++/CLI especially since the code templates are modelled after how the C# compiler works not on how the C++ compiler works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文