.net 源代码(C#、VB.net)在其他(非英语)语言中是什么样子?

发布于 2024-09-24 13:01:51 字数 252 浏览 7 评论 0原文

正如标题所说,我只是有点好奇......我看到一些欧洲开源项目发布了源代码,但它们在语法上都是相同的。中文、日文或其他更复杂的基于字符的语言又如何呢?

更新:我想这有点误导。我问的是“传统”.Net 语言,如 C#、VB.net,甚至可能是 F# 等。我现在了解到,正在创建更新的 .Net 语言,主要是为了支持非英语书面和口语,并且它们看起来与用 VB.net 和 C# 编写的类似源代码非常不同。

我会尝试给一些人投票,并将我想要的问题的答案标记为答案。

As the title says, I am just a little curious...I have seen some European open-source projects post the source, but it was all syntactically identical. What about Chinese or Japanese or other more complex character-based languages?

UPDATE: This was a little misleading I guess. I was asking about the "traditional" .Net languages like C#, VB.net, maybe even F# etc. I understand now that there are newer .Net languages that are being create primarily to support non-English written and spoken languages and that they appear very dissimilar to similar source written in VB.net and C#.

I will try to up vote a few people and mark the answer to my intended question as the answer.

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

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

发布评论

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

评论(3

孤者何惧 2024-10-01 13:01:51

关键字是英文的,因此大多数代码在任何语言中都是相同的。有些人使用当地语言作为标识符名称,其他人也保留英语名称。

以下是使用瑞典标识符的某些代码的示例:

public class StenSaxPåse {

  public enum Värde { Papper = 0, Sten = 1, Sax = 2 }

  private Värde _värde;

  public StenSaxPåse(Random slump) {
    _värde = (Värde)slump.Next(3);
  }

  public bool SammaSom(StenSaxPåse andra) {
    return _värde == andra._värde;
  }

  public bool Slår(StenSaxPåse andra) {
    return
      (_värde == Värde.Papper && andra._värde == Värde.Sten) ||
      (_värde == Värde.Sten && andra._värde == Värde.Sax) ||
      (_värde == Värde.Sax && andra._värde == Värde.Papper);
  }

  public override string ToString() {
    switch (_värde) {
      case Värde.Papper: return "PAPPER";
      case Värde.Sten: return "STEN";
      default: return "SAX";
    }
  }

}

The keywords are in english, so most of the code is the same in any language. Some people use local languages for identifier names, others keep the names in english too.

Here's an example of how some code would look like with swedish identifiers:

public class StenSaxPåse {

  public enum Värde { Papper = 0, Sten = 1, Sax = 2 }

  private Värde _värde;

  public StenSaxPåse(Random slump) {
    _värde = (Värde)slump.Next(3);
  }

  public bool SammaSom(StenSaxPåse andra) {
    return _värde == andra._värde;
  }

  public bool Slår(StenSaxPåse andra) {
    return
      (_värde == Värde.Papper && andra._värde == Värde.Sten) ||
      (_värde == Värde.Sten && andra._värde == Värde.Sax) ||
      (_värde == Värde.Sax && andra._värde == Värde.Papper);
  }

  public override string ToString() {
    switch (_värde) {
      case Värde.Papper: return "PAPPER";
      case Värde.Sten: return "STEN";
      default: return "SAX";
    }
  }

}
与风相奔跑 2024-10-01 13:01:51

当然,这取决于语言。

个别语言的语法和规则不会改变。例如,无论开发什么语言,C# 仍将使用相同的字符和关键字。但是,变量名称等可以使用(几乎)任何 unicode 字符,这意味着使用其他语言的人可以使用非英语命名。

话虽如此,没有什么可以阻止人们使用本质上不是英语的标识符来创建新的 .NET 语言 - 示例包括 Lexico 印地语编程语言Farsi.NET

以下是 Lexico 网站 中的一些示例代码:

incluya "System.Windows.Forms" 
clase ventana derivada_de "System.Windows.Forms.Form" { publicos: mensajes: ventana copie "Este es el título de mi primera ventana" en ventana.text }

This, of course, depends on the language.

The individual language syntax and rules will not change. For example, C# will still use the same characters and keywords, no matter what language is being developed. However, variable names and the like are allowed to use (nearly) any unicode characters, which means people in other languages can use non-English naming.

That being said, there is nothing preventing people from making a new .NET language with identifiers that are not English in nature - Examples include Lexico, the Hindi Programming Language, and Farsi.NET.

Here's some sample code from the Lexico site:

incluya "System.Windows.Forms" 
clase ventana derivada_de "System.Windows.Forms.Form" { publicos: mensajes: ventana copie "Este es el título de mi primera ventana" en ventana.text }
贵在坚持 2024-10-01 13:01:51

语法相同。编程语言在语法上应该是通用的。

Syntactically identical. A programming language should be syntactically universal.

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