AnsweredAssumed Answered

PI SDK problem (of my own making!)

Question asked by Chris_Hawkins on Jun 30, 2016
Latest reply on Jul 1, 2016 by Chris_Hawkins

I attach screenshots from two versions of the same routine. IOne written in VB.NET (which works) and one writtemn in C# (which doesn't work). While recognising the problem lies with my limited grasp of C# I'd appreciate guidance as to waht I'm doing wrong.

The offending lines in C# contain DirectCast (which I don't think is available in C#) if the PIPoint is a digital state and the PIPoint piVal.Value which I wish to cast as a string


     myTemp = Convert.ToString(piVal.TimeStamp.LocalDate) + delimiter + " " + DirectCast(piVal.Value, DigitalState).Name;


     myTemp = Convert.ToString(piVal.TimeStamp.LocalDate) + delimiter + " " + piVal.Value.ToString();

Note that I founfd the construct piVal.Value.ToString() in a PI SDK coding example on the Web. Even if I truncate to use Convert.ToString(piVal.Value) or just piVal.piValue it still doesn't work

The error messsages are shown in screeshot 3



The above in VB works

The below in C# doesn't work



with error messages