Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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):
Updated 2-May-19 1:42am

1 solution

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++)
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)
Share this answer
QuantumNova 2-May-19 7:54am    
thanks, much appreciate the help :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900