Click here to Skip to main content
14,421,922 members
Rate this:
Please Sign up or sign in to 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):
Posted
Updated 2-May-19 2:42am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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)
   {
   ...
   
Comments
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100