CODE help!

I am getting an error that is:
error C3845: 'Telemetry1::routineTlm1::f_tempTopPlate': only static data members can be initialized inside a ref class or value type

error C4368: cannot define 'f_tempTopPlate' as a member of managed 'Telemetry1::routineTlm1': mixed types are not supported

for the code:

#pragma once

#include "stdafx.h"
#include "Form1.h"

using namespace System;

public ref class routineTlm1
{
public:
float f_tempTopPlate[1] = 50;
}
I am using visual studio windows form application with c#

Can someone help?
Last edited on
I know very little about c#, but judging from the error which states "only static data members can be initialized inside a ref class," and you very clearly have a "ref class routineTlm1" with a data member "f_tempTopPlate[1]" very clearly being initialized and set to 50, my guess is that you can't do that and you should probably make yourself a constructor instead. Or you can make it static apparently according to the message, too.
I tried making it a static, but that just brought more errors. I'll try making a constructor instead.
Making a constructor got it to work. Thanks!
Topic archived. No new replies allowed.