将简单的代码片段从Python转换为C# [英] Converting simple pieces of code from Python to C#
本文介绍了将简单的代码片段从Python转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
各位朋友,我无法将一些简单的代码从python转换为C#,如果有人能帮助我,我将非常感谢,谢谢
这里是python中的代码
我尝试过:
hello friends, I am having trouble converting a few simple pieces of code from python to C#, if someone could please help me it would be very much appreciated, thanks
here is the code in python below
What I have tried:
nums = [1,3,6,9,8,2,9,3]
n = len(nums)
for i in range(n):
推荐答案
如果你不能转换它,那么你需要更详细地研究这两种语言......
If you can't convert that, then you need to study both languages in a lot more detail...
int[] nums = {1, 3, 6, 9, 8, 2, 9, 3};
int n = nums.Length;
for (int i = 0; i < n; i++)
{
...
但是如果你使用我来在这里索引nums中的值,然后这是更好的:
But if you are using i to index the values in nums here, then this is better:
int[] nums = {1, 3, 6, 9, 8, 2, 9, 3};
foreach (int num in numbs)
{
...
这篇关于将简单的代码片段从Python转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文