-> Length

Feb 10, 2012 at 10:21pm
#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
array<double>^ samples = gcnew array<double>(50);

// Generate random element values
Random^ generator = gcnew Random;
for(int i = 0; i < samples->Length; i++)
samples[i] = 100.0*generator->NextDouble();

//output the samples
Console::WriteLine(L"The aray contains the following values:");
for(int i = 0; i < samples->Length; i++)What does -> Length do here in this for loop?
{
Console::Write(L"{0,10:F2}", samples[i]);
if((i+1)%5 == 0) //For each time the loop goes divisible by 5, make a new line
Console::WriteLine();
}
//Find max value
double max(0);
for each(double sample in samples)
if(max < sample)
max = sample;

Console::WriteLine(L"The maximum value in the array is {0:F2}", max);

Console::ReadLine();

return 0;
Feb 10, 2012 at 11:08pm
closed account (zb0S216C)
This is Python/CLI - Microsoft's sorry excuse for garbage collection. In Python, though, the arrow operator (I forgot its actual name) is used with pointers, which effectively dereferences the pointer on the left-hand side, and reads/writes/invokes the member on the right-hand side after dereferencing.

I don't know if this applies to Python/CLI.

Wazzak
Last edited on Feb 10, 2012 at 11:09pm
Feb 10, 2012 at 11:10pm
Yeah, I'm learning them concurrently in the book that I'm reading. So some of the stuff that the guy covers in CLI isn't quite as clear as it is when he covers it in native Python.
Feb 10, 2012 at 11:17pm
closed account (zb0S216C)
I'd suggest pushing Python/CLI to one side whilst learning Python. Try obtaining another book that focuses solely on Python, and omits non-standard extensions - Python Primer comes to mind.

Wazzak
Last edited on Feb 10, 2012 at 11:17pm
Feb 10, 2012 at 11:21pm
The guy rather pushes it to the back burner to be honest. I could just skip them I suppose.
Topic archived. No new replies allowed.