Home > Net >  Compile errors: CS0126 need a type can be converted to "ITeraPacketElement"
Compile errors: CS0126 need a type can be converted to "ITeraPacketElement"

Time:11-09

C #, please help to point out how to solve, thank you, environment: vs2019, the.net 4.7.2
The code is as follows:
 private ITeraPacketElement FindStruc (Message Message, TeraMessageReader reader=null) 
{
If (reader==null) {reader=new TeraMessageReader (message); }
Ushort offset.
Ushort count;
Long offset_position;
Long count_position;
Try
{
Offset=reader. ReadUInt16 ();
Offset_position=reader. BaseStream. Position;
Count=reader. ReadUInt16 ();
Count_position=reader. BaseStream. Position;
}
//If the an error happens, we have reached the end of the stream, the not structure can be found.
Catch {throw new Exception (" Should not happens "); }

If (CheckString (message, offset_position))
{
The Debug. WriteLine (" String found: offset="+ offset_position);
//is string, check next thing
FindStruc (message, reader);
return;//error
}
If (CheckArray (message, offset_position count_position))
{
The Debug. WriteLine (" String found: offset="+ count_position);
//is an array, the check next thing
FindStruc (message, reader);
return;//error
}

//Nothing have had been found, stop.
return;//error

}

CodePudding user response:

Looks like is existing projects, suggest you and colleagues to discuss first,
Or, as a newcomer to put this project on a first put, do some other task easier introduction,

CodePudding user response:

Return ITeraPacketElement object of type, the return; Would be an error,
ITeraPacketElement element=new ITeraPacketElement ();
The return element. This is not an error, but the use of this type ITeraPacketElement method, reflects what his role is you want

CodePudding user response:

First look at your private function definition ITeraPacketElement FindStruc (Message Message, TeraMessageReader reader=null), need to return a ITeraPacketElement type of object, but three mistakes in your place is direct return, no return objects, also is natural complains

CodePudding user response:

The first line of the second word indicates this method (function) return value should be an implementation of a ITeraPacketElement interface instance of the object, and errors are returned directly, is empty. So the anomaly.
  •  Tags:  
  • C#
  • Related