帮助C#语法 [英] Help with C# Syntax
问题描述
我暂时没有写过C#。 我收到以下错误和所有"="在Visual Studio编辑器中,在
BOLD 的所有代码中变为红色。 这是来自HL7消息编写者的示例代码。 我认为这是需要更新的旧C#语法。 它使用的是.NET 2.0框架。 谢谢
I haven't written C# for a while. I am getting the following error and all the "=" are turning red in the Visual Studio editor in all the code that's BOLD. This is sample code from HL7 message writer. I think this is older C# syntax that needs to be updated. It's using .NET 2.0 framework. Thanks
错误: 类,结构中的标记'='无效,或接口成员声明
Error: Invalid token '=' in class, struct, or interface member declaration
          PipeParser 解析器= new PipeParser ();
PipeParser parser = new PipeParser();
NHapi.Model.V231.Message。 QRY_R02 qry
= new
NHapi.Model.V231.Message。 QRY_R02 ();
         
qry.MSH.MessageType.MessageType.Value = " QRY" ;
qry.MSH.MessageType.MessageType.Value ="QRY";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.MessageType.TriggerEvent.Value = " R02" ;
qry.MSH.MessageType.TriggerEvent.Value = "R02";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.MessageType.MessageStructure.Value = " QRY_R02" ;
qry.MSH.MessageType.MessageStructure.Value = "QRY_R02";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.FieldSeparator.Value = " |" ;
qry.MSH.FieldSeparator.Value = "|";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.SendingApplication.NamespaceID.Value = " CohieCentral" ;
qry.MSH.SendingApplication.NamespaceID.Value="CohieCentral";
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.SendingFacility.NamespaceID.Value = " COHIE" ;
qry.MSH.SendingFacility.NamespaceID.Value = "COHIE";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.ReceivingApplication.NamespaceID.Value = " Clinical
数据提供商" ;
qry.MSH.ReceivingApplication.NamespaceID.Value="Clinical Data Provider";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.ReceivingFacility.NamespaceID.Value =设施; 强> 跨度>
  ;&NBSP;&NBSP; qry.MSH.EncodingCharacters.Value = @" ^〜\&" ;
qry.MSH.EncodingCharacters.Value = @"^~\&";
qry.MSH.VersionID.VersionID.Value = " 2.3.1" ;
qry.MSH.VersionID.VersionID.Value = "2.3.1";
qry.MSH.DateTimeOfMessage.TimeOfAnEvent.SetLongDate( DateTime 。现在;;
qry.MSH.DateTimeOfMessage.TimeOfAnEvent.SetLongDate(DateTime.Now);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.MSH.MessageControlID.Value = messageControlId; 强> 跨度>
的 <强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP; qry.MSH.ProcessingID.ProcessingID.Value = " P" ;
qry.MSH.ProcessingID.ProcessingID.Value="P";
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; XCN st = qry.QRD.getWhoSubjectFilter(0);
  ;&NBSP;&NBSP; st.AssigningAuthority.UniversalID.Value =设施; 强> 跨度>
的 <强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP; st.IDNumber.Value = mrn; qry.QRD.QueryDateTime.TimeOfAnEvent.SetLongDate( 日期时间 。现在;
st.IDNumber.Value = mrn;qry.QRD.QueryDateTime.TimeOfAnEvent.SetLongDate(DateTime.Now);
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.QRD.QueryFormatCode.Value = " R" ;
qry.QRD.QueryFormatCode.Value = "R";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; qry.QRD.QueryPriority.Value = 强> <跨度>&NBSP; 跨度> 跨度>的 "我" ;
qry.QRD.QueryPriority.Value = "I";
<强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; CE什么= qry.QRD.getWhatSubjectFilter(0); 强> 跨度>
的 <强>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; what.Identifier.Value = " RES" ;
what.Identifier.Value = "RES";
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <跨度>&NBSP; 跨度> 跨度>的 返回 parser.encode(qry);
return parser.encode(qry);
推荐答案
这些是我期望的错误代码在类中,但不在方法中。我注意到你以"返回"结尾声明,所以看起来你打算在一个方法中。您应该检查所有开始和结束括号,以使
确保代码没有意外地在方法之外结束。
Those are the sorts of errors I would expect if the code is in a class but not in a method. I notice you end with a "return" statement, so it looks like you intend it to be in a method. You should check all the opening and closing braces to make sure that code has not ended up outside a method by accident.
这篇关于帮助C#语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!