yijunyu/c-to-rust huggingface dataset:
// Original:
public WindowProtectRecord(int options) {_options = options;}

// Translation:
public WindowProtectRecord(int options){_options = options;}
// Original:
public UnbufferedCharStream(int bufferSize) {n = 0;data = new int[bufferSize];}

// Translation:
public UnbufferedCharStream(int bufferSize){n = 0;data = new int[bufferSize];}
// Original:
public GetOperationsResult getOperations(GetOperationsRequest request) {request = beforeClientExecution(request);return executeGetOperations(request);}

// Translation:
public virtual GetOperationsResponse GetOperations(GetOperationsRequest request){var options = new InvokeOptions();options.RequestMarshaller = GetOperationsRequestMarshaller.Instance;options.ResponseUnmarshaller = GetOperationsResponseUnmarshaller.Instance;return Invoke<GetOperationsResponse>(request, options);}
// Original:
public void copyRawTo(byte[] b, int o) {NB.encodeInt32(b, o, w1);NB.encodeInt32(b, o + 4, w2);NB.encodeInt32(b, o + 8, w3);NB.encodeInt32(b, o + 12, w4);NB.encodeInt32(b, o + 16, w5);}

// Translation:
public virtual void CopyRawTo(byte[] b, int o){NB.EncodeInt32(b, o, w1);NB.EncodeInt32(b, o + 4, w2);NB.EncodeInt32(b, o + 8, w3);NB.EncodeInt32(b, o + 12, w4);NB.EncodeInt32(b, o + 16, w5);}
// Original:
public WindowOneRecord(RecordInputStream in) {field_1_h_hold            = in.readShort();field_2_v_hold            = in.readShort();field_3_width             = in.readShort();field_4_height            = in.readShort();field_5_options           = in.readShort();field_6_active_sheet      = in.readShort();field_7_first_visible_tab = in.readShort();field_8_num_selected_tabs = in.readShort();field_9_tab_width_ratio   = in.readShort();}

// Translation:
public WindowOneRecord(RecordInputStream in1){field_1_h_hold = in1.ReadShort();field_2_v_hold = in1.ReadShort();field_3_width = in1.ReadShort();field_4_height = in1.ReadShort();field_5_options = in1.ReadShort();field_6_active_sheet = in1.ReadShort();field_7_first_visible_tab = in1.ReadShort();field_8_num_selected_tabs = in1.ReadShort();field_9_tab_width_ratio = in1.ReadShort();}
// Original:
public StopWorkspacesResult stopWorkspaces(StopWorkspacesRequest request) {request = beforeClientExecution(request);return executeStopWorkspaces(request);}

// Translation:
public virtual StopWorkspacesResponse StopWorkspaces(StopWorkspacesRequest request){var options = new InvokeOptions();options.RequestMarshaller = StopWorkspacesRequestMarshaller.Instance;options.ResponseUnmarshaller = StopWorkspacesResponseUnmarshaller.Instance;return Invoke<StopWorkspacesResponse>(request, options);}
// Original:
public void close() throws IOException {if (isOpen) {isOpen = false;try {dump();} finally {try {channel.truncate(fileLength);} finally {try {channel.close();} finally {fos.close();}}}}}

// Translation:
public void close() throws IOException{if (isOpen){isOpen = false;try{dump();}finally{try{channel.truncate(fileLength);}finally{try{channel.close();}finally{fos.close();}}}}}
// Original:
public DescribeMatchmakingRuleSetsResult describeMatchmakingRuleSets(DescribeMatchmakingRuleSetsRequest request) {request = beforeClientExecution(request);return executeDescribeMatchmakingRuleSets(request);}

// Translation:
public virtual DescribeMatchmakingRuleSetsResponse DescribeMatchmakingRuleSets(DescribeMatchmakingRuleSetsRequest request){var options = new InvokeOptions();options.RequestMarshaller = DescribeMatchmakingRuleSetsRequestMarshaller.Instance;options.ResponseUnmarshaller = DescribeMatchmakingRuleSetsResponseUnmarshaller.Instance;return Invoke<DescribeMatchmakingRuleSetsResponse>(request, options);}
// Original:
public String getPronunciation(int wordId, char surface[], int off, int len) {return null; }

// Translation:
public string GetPronunciation(int wordId, char[] surface, int off, int len){return null; }
// Original:
public String getPath() {return pathStr;}

// Translation:
public virtual string GetPath(){return pathStr;}
// Original:
public static double devsq(double[] v) {double r = Double.NaN;if (v!=null && v.length >= 1) {double m = 0;double s = 0;int n = v.length;for (int i=0; i<n; i++) {s += v[i];}m = s / n;s = 0;for (int i=0; i<n; i++) {s += (v[i]- m) * (v[i] - m);}r = (n == 1)? 0: s;}return r;}

// Translation:
public static double devsq(double[] v){double r = double.NaN;if (v != null && v.Length >= 1){double m = 0;double s = 0;int n = v.Length;for (int i = 0; i < n; i++){s += v[i];}m = s / n;s = 0;for (int i = 0; i < n; i++){s += (v[i] - m) * (v[i] - m);}r = (n == 1)? 0: s;}return r;}
// Original:
public DescribeResizeResult describeResize(DescribeResizeRequest request) {request = beforeClientExecution(request);return executeDescribeResize(request);}

// Translation:
public virtual DescribeResizeResponse DescribeResize(DescribeResizeRequest request){var options = new InvokeOptions();options.RequestMarshaller = DescribeResizeRequestMarshaller.Instance;options.ResponseUnmarshaller = DescribeResizeResponseUnmarshaller.Instance;return Invoke<DescribeResizeResponse>(request, options);}
// Original:
public final boolean hasPassedThroughNonGreedyDecision() {return passedThroughNonGreedyDecision;}

// Translation:
public bool hasPassedThroughNonGreedyDecision(){return passedThroughNonGreedyDecision;}
// Original:
public int end() {return end(0);}

// Translation:
public int end(){return end(0);}
// Original:
public void traverse(CellHandler handler) {int firstRow = range.getFirstRow();int lastRow = range.getLastRow();int firstColumn = range.getFirstColumn();int lastColumn = range.getLastColumn();final int width = lastColumn - firstColumn + 1;SimpleCellWalkContext ctx = new SimpleCellWalkContext();Row currentRow = null;Cell currentCell = null;for (ctx.rowNumber = firstRow; ctx.rowNumber <= lastRow; ++ctx.rowNumber) {currentRow = sheet.getRow(ctx.rowNumber);if (currentRow == null) {continue;}for (ctx.colNumber = firstColumn; ctx.colNumber <= lastColumn; ++ctx.colNumber) {currentCell = currentRow.getCell(ctx.colNumber);if (currentCell == null) {continue;}if (isEmpty(currentCell) && !traverseEmptyCells) {continue;}long rowSize = ArithmeticUtils.mulAndCheck((long)ArithmeticUtils.subAndCheck(ctx.rowNumber, firstRow), (long)width);ctx.ordinalNumber = ArithmeticUtils.addAndCheck(rowSize, (ctx.colNumber - firstColumn + 1));handler.onCell(currentCell, ctx);}}}

// Translation:
public void Traverse(ICellHandler handler){int firstRow = range.FirstRow;int lastRow = range.LastRow;int firstColumn = range.FirstColumn;int lastColumn = range.LastColumn;int width = lastColumn - firstColumn + 1;SimpleCellWalkContext ctx = new SimpleCellWalkContext();IRow currentRow = null;ICell currentCell = null;for (ctx.rowNumber = firstRow; ctx.rowNumber <= lastRow; ++ctx.rowNumber){currentRow = sheet.GetRow(ctx.rowNumber);if (currentRow == null){continue;}for (ctx.colNumber = firstColumn; ctx.colNumber <= lastColumn; ++ctx.colNumber){currentCell = currentRow.GetCell(ctx.colNumber);if (currentCell == null){continue;}if (IsEmpty(currentCell) && !traverseEmptyCells){continue;}ctx.ordinalNumber =(ctx.rowNumber - firstRow) * width +(ctx.colNumber - firstColumn + 1);handler.OnCell(currentCell, ctx);}}}
// Original:
public int getReadIndex() {return pos;}

// Translation:
public int GetReadIndex(){return _ReadIndex;}
// Original:
public int compareTo(ScoreTerm other) {if (this.boost == other.boost)return other.bytes.get().compareTo(this.bytes.get());elsereturn Float.compare(this.boost, other.boost);}

// Translation:
public virtual int CompareTo(ScoreTerm other){if (Term.BytesEquals(other.Term)){return 0; }if (this.Boost == other.Boost){return other.Term.CompareTo(this.Term);}else{return this.Boost.CompareTo(other.Boost);}}
// Original:
public int normalize(char s[], int len) {for (int i = 0; i < len; i++) {switch (s[i]) {case FARSI_YEH:case YEH_BARREE:s[i] = YEH;break;case KEHEH:s[i] = KAF;break;case HEH_YEH:case HEH_GOAL:s[i] = HEH;break;case HAMZA_ABOVE: len = delete(s, i, len);i--;break;default:break;}}return len;}

// Translation:
public virtual int Normalize(char[] s, int len){for (int i = 0; i < len; i++){switch (s[i]){case FARSI_YEH:case YEH_BARREE:s[i] = YEH;break;case KEHEH:s[i] = KAF;break;case HEH_YEH:case HEH_GOAL:s[i] = HEH;break;case HAMZA_ABOVE: len = StemmerUtil.Delete(s, i, len);i--;break;default:break;}}return len;}
// Original:
public void serialize(LittleEndianOutput out) {out.writeShort(_options);}

// Translation:
public override void Serialize(ILittleEndianOutput out1){out1.WriteShort(_options);}
// Original:
public DiagnosticErrorListener(boolean exactOnly) {this.exactOnly = exactOnly;}

// Translation:
public DiagnosticErrorListener(bool exactOnly){this.exactOnly = exactOnly;}
// Original:
public KeySchemaElement(String attributeName, KeyType keyType) {setAttributeName(attributeName);setKeyType(keyType.toString());}

// Translation:
public KeySchemaElement(string attributeName, KeyType keyType){_attributeName = attributeName;_keyType = keyType;}
// Original:
public GetAssignmentResult getAssignment(GetAssignmentRequest request) {request = beforeClientExecution(request);return executeGetAssignment(request);}

// Translation:
public virtual GetAssignmentResponse GetAssignment(GetAssignmentRequest request){var options = new InvokeOptions();options.RequestMarshaller = GetAssignmentRequestMarshaller.Instance;options.ResponseUnmarshaller = GetAssignmentResponseUnmarshaller.Instance;return Invoke<GetAssignmentResponse>(request, options);}
// Original:
public boolean hasObject(AnyObjectId id) {return findOffset(id) != -1;}

// Translation:
public virtual bool HasObject(AnyObjectId id){return FindOffset(id) != -1;}
// Original:
public GroupingSearch setAllGroups(boolean allGroups) {this.allGroups = allGroups;return this;}

// Translation:
public virtual GroupingSearch SetAllGroups(bool allGroups){this.allGroups = allGroups;return this;}
// Original:
public synchronized void setMultiValued(String dimName, boolean v) {DimConfig ft = fieldTypes.get(dimName);if (ft == null) {ft = new DimConfig();fieldTypes.put(dimName, ft);}ft.multiValued = v;}

// Translation:
public virtual void SetMultiValued(string dimName, bool v){lock (this){if (!fieldTypes.TryGetValue(dimName, out DimConfig fieldType)){fieldTypes[dimName] = new DimConfig { IsMultiValued = v };}else{fieldType.IsMultiValued = v;}}}
// Original:
public int getCellsVal() {Iterator<Character> i = cells.keySet().iterator();int size = 0;for (; i.hasNext();) {Character c = i.next();Cell e = at(c);if (e.cmd >= 0) {size++;}}return size;}

// Translation:
public int GetCellsVal(){int size = 0;foreach (char c in cells.Keys){Cell e = At(c);if (e.cmd >= 0){size++;}}return size;}
// Original:
public DeleteVoiceConnectorResult deleteVoiceConnector(DeleteVoiceConnectorRequest request) {request = beforeClientExecution(request);return executeDeleteVoiceConnector(request);}

// Translation:
public virtual DeleteVoiceConnectorResponse DeleteVoiceConnector(DeleteVoiceConnectorRequest request){var options = new InvokeOptions();options.RequestMarshaller = DeleteVoiceConnectorRequestMarshaller.Instance;options.ResponseUnmarshaller = DeleteVoiceConnectorResponseUnmarshaller.Instance;return Invoke<DeleteVoiceConnectorResponse>(request, options);}
// Original:
public DeleteLifecyclePolicyResult deleteLifecyclePolicy(DeleteLifecyclePolicyRequest request) {request = beforeClientExecution(request);return executeDeleteLifecyclePolicy(request);}

// Translation:
public virtual DeleteLifecyclePolicyResponse DeleteLifecyclePolicy(DeleteLifecyclePolicyRequest request){var options = new InvokeOptions();options.RequestMarshaller = DeleteLifecyclePolicyRequestMarshaller.Instance;options.ResponseUnmarshaller = DeleteLifecyclePolicyResponseUnmarshaller.Instance;return Invoke<DeleteLifecyclePolicyResponse>(request, options);}
// Original:
public void write(byte[] b) {int len = b.length;checkPosition(len);System.arraycopy(b, 0, _buf, _writeIndex, len);_writeIndex += len;}

// Translation:
public void Write(byte[] b){int len = b.Length;CheckPosition(len);System.Array.Copy(b, 0, _buf, _writeIndex, len);_writeIndex += len;}
// Original:
public RebaseResult getRebaseResult() {return this.rebaseResult;}

// Translation:
public virtual RebaseResult GetRebaseResult(){return this.rebaseResult;}
// Original:
public static int getNearestSetSize(int maxNumberOfValuesExpected,float desiredSaturation) {for (int i = 0; i < usableBitSetSizes.length; i++) {int numSetBitsAtDesiredSaturation = (int) (usableBitSetSizes[i] * desiredSaturation);int estimatedNumUniqueValues = getEstimatedNumberUniqueValuesAllowingForCollisions(usableBitSetSizes[i], numSetBitsAtDesiredSaturation);if (estimatedNumUniqueValues > maxNumberOfValuesExpected) {return usableBitSetSizes[i];}}return -1;}

// Translation:
public static int GetNearestSetSize(int maxNumberOfValuesExpected,float desiredSaturation){foreach (var t in from t in _usableBitSetSizeslet numSetBitsAtDesiredSaturation = (int) (t*desiredSaturation)let estimatedNumUniqueValues = GetEstimatedNumberUniqueValuesAllowingForCollisions(t, numSetBitsAtDesiredSaturation) where estimatedNumUniqueValues > maxNumberOfValuesExpected select t){return t;}return -1;}
// Original:
public DescribeDashboardResult describeDashboard(DescribeDashboardRequest request) {request = beforeClientExecution(request);return executeDescribeDashboard(request);}

// Translation:
public virtual DescribeDashboardResponse DescribeDashboard(DescribeDashboardRequest request){var options = new InvokeOptions();options.RequestMarshaller = DescribeDashboardRequestMarshaller.Instance;options.ResponseUnmarshaller = DescribeDashboardResponseUnmarshaller.Instance;return Invoke<DescribeDashboardResponse>(request, options);}
// Original:
public CreateSegmentResult createSegment(CreateSegmentRequest request) {request = beforeClientExecution(request);return executeCreateSegment(request);}

// Translation:
public virtual CreateSegmentResponse CreateSegment(CreateSegmentRequest request){var options = new InvokeOptions();options.RequestMarshaller = CreateSegmentRequestMarshaller.Instance;options.ResponseUnmarshaller = CreateSegmentResponseUnmarshaller.Instance;return Invoke<CreateSegmentResponse>(request, options);}
// Original:
public String toString() {StringBuilder buffer = new StringBuilder();buffer.append("[DBCELL]\n");buffer.append("    .rowoffset = ").append(HexDump.intToHex(field_1_row_offset)).append("\n");for (int k = 0; k < field_2_cell_offsets.length; k++) {buffer.append("    .cell_").append(k).append(" = ").append(HexDump.shortToHex(field_2_cell_offsets[ k ])).append("\n");}buffer.append("[/DBCELL]\n");return buffer.toString();}

// Translation:
public override String ToString(){StringBuilder buffer = new StringBuilder();buffer.Append("[DBCELL]\n");buffer.Append("    .rowoffset       = ").Append(StringUtil.ToHexString(RowOffset)).Append("\n");for (int k = 0; k < field_2_cell_offsets.Length; k++){buffer.Append("    .cell_").Append(k).Append(" = ").Append(HexDump.ShortToHex(field_2_cell_offsets[k])).Append("\n");}buffer.Append("[/DBCELL]\n");return buffer.ToString();}
// Original:
public List<String> getUndeletedList() {return undeletedList;}

// Translation:
public virtual IList<string> GetUndeletedList(){return undeletedList;}
// Original:
public String toString() {return "[INTERFACEEND/]\n";}

// Translation:
public override String ToString(){return "[INTERFACEEND/]\n";}
// Original:
public MergeScheduler clone() {return this;}

// Translation:
public override object Clone(){return this;}
// Original:
public PlainTextDictionary(Reader reader) {in = new BufferedReader(reader);}

// Translation:
public PlainTextDictionary(TextReader reader){@in = reader;}
// Original:
public StringBuilder append(CharSequence csq) {if (csq == null) {appendNull();} else {append0(csq, 0, csq.length());}return this;}

// Translation:
public java.lang.StringBuilder append(java.lang.CharSequence csq){if (csq == null){appendNull();}else{append0(csq, 0, csq.Length);}return this;}
// Original:
public ListAssociatedStacksResult listAssociatedStacks(ListAssociatedStacksRequest request) {request = beforeClientExecution(request);return executeListAssociatedStacks(request);}

// Translation:
public virtual ListAssociatedStacksResponse ListAssociatedStacks(ListAssociatedStacksRequest request){var options = new InvokeOptions();options.RequestMarshaller = ListAssociatedStacksRequestMarshaller.Instance;options.ResponseUnmarshaller = ListAssociatedStacksResponseUnmarshaller.Instance;return Invoke<ListAssociatedStacksResponse>(request, options);}
// Original:
public static double avedev(double[] v) {double r = 0;double m = 0;double s = 0;for (int i=0, iSize=v.length; i<iSize; i++) {s += v[i];}m = s / v.length;s = 0;for (int i=0, iSize=v.length; i<iSize; i++) {s += Math.abs(v[i]-m);}r = s / v.length;return r;}

// Translation:
public static double avedev(double[] v){double r = 0;double m = 0;double s = 0;for (int i = 0, iSize = v.Length; i < iSize; i++){s += v[i];}m = s / v.Length;s = 0;for (int i = 0, iSize = v.Length; i < iSize; i++){s += Math.Abs(v[i] - m);}r = s / v.Length;return r;}
// Original:
public DescribeByoipCidrsResult describeByoipCidrs(DescribeByoipCidrsRequest request) {request = beforeClientExecution(request);return executeDescribeByoipCidrs(request);}

// Translation:
public virtual DescribeByoipCidrsResponse DescribeByoipCidrs(DescribeByoipCidrsRequest request){var options = new InvokeOptions();options.RequestMarshaller = DescribeByoipCidrsRequestMarshaller.Instance;options.ResponseUnmarshaller = DescribeByoipCidrsResponseUnmarshaller.Instance;return Invoke<DescribeByoipCidrsResponse>(request, options);}
// Original:
public GetDiskResult getDisk(GetDiskRequest request) {request = beforeClientExecution(request);return executeGetDisk(request);}

// Translation:
public virtual GetDiskResponse GetDisk(GetDiskRequest request){var options = new InvokeOptions();options.RequestMarshaller = GetDiskRequestMarshaller.Instance;options.ResponseUnmarshaller = GetDiskResponseUnmarshaller.Instance;return Invoke<GetDiskResponse>(request, options);}
// Original:
public DBClusterParameterGroup createDBClusterParameterGroup(CreateDBClusterParameterGroupRequest request) {request = beforeClientExecution(request);return executeCreateDBClusterParameterGroup(request);}

// Translation:
public virtual CreateDBClusterParameterGroupResponse CreateDBClusterParameterGroup(CreateDBClusterParameterGroupRequest request){var options = new InvokeOptions();options.RequestMarshaller = CreateDBClusterParameterGroupRequestMarshaller.Instance;options.ResponseUnmarshaller = CreateDBClusterParameterGroupResponseUnmarshaller.Instance;return Invoke<CreateDBClusterParameterGroupResponse>(request, options);}
// Original:
public static CharBuffer wrap(char[] array, int start, int charCount) {Arrays.checkOffsetAndCount(array.length, start, charCount);CharBuffer buf = new ReadWriteCharArrayBuffer(array);buf.position = start;buf.limit = start + charCount;return buf;}

// Translation:
public static java.nio.CharBuffer wrap(char[] array_1, int start, int charCount){java.util.Arrays.checkOffsetAndCount(array_1.Length, start, charCount);java.nio.CharBuffer buf = new java.nio.ReadWriteCharArrayBuffer(array_1);buf._position = start;buf._limit = start + charCount;return buf;}
// Original:
public SubmoduleStatusType getType() {return type;}

// Translation:
public virtual SubmoduleStatusType GetType(){return type;}
// Original:
public DescribeGameServerGroupResult describeGameServerGroup(DescribeGameServerGroupRequest request) {request = beforeClientExecution(request);return executeDescribeGameServerGroup(request);}

// Translation:
public virtual DescribeGameServerGroupResponse DescribeGameServerGroup(DescribeGameServerGroupRequest request){var options = new InvokeOptions();options.RequestMarshaller = DescribeGameServerGroupRequestMarshaller.Instance;options.ResponseUnmarshaller = DescribeGameServerGroupResponseUnmarshaller.Instance;return Invoke<DescribeGameServerGroupResponse>(request, options);}
// Original:
public Pattern pattern() {return pattern;}

// Translation:
public java.util.regex.Pattern pattern(){return _pattern;}
// Original:
public V setValue(V object) {throw new UnsupportedOperationException();}

// Translation:
public virtual V setValue(V @object){throw new System.NotSupportedException();}
// Original:
public StringBuilder stem(CharSequence word) {CharSequence cmd = stemmer.getLastOnPath(word);if (cmd == null)return null;buffer.setLength(0);buffer.append(word);Diff.apply(buffer, cmd);if (buffer.length() > 0)return buffer;elsereturn null;}

// Translation:
public StringBuilder Stem(string word){string cmd = stemmer.GetLastOnPath(word);if (cmd == null)return null;buffer.Length = 0;buffer.Append(word);Diff.Apply(buffer, cmd);if (buffer.Length > 0)return buffer;elsereturn null;}
// Original:
public RenameFaceRequest() {super("CloudPhoto", "2017-07-11", "RenameFace", "cloudphoto");setProtocol(ProtocolType.HTTPS);}

// Translation:
public RenameFaceRequest(): base("CloudPhoto", "2017-07-11", "RenameFace", "cloudphoto", "openAPI"){Protocol = ProtocolType.HTTPS;}
// Original:
public char requireChar(Map<String,String> args, String name) {return require(args, name).charAt(0);}

// Translation:
public virtual char RequireChar(IDictionary<string, string> args, string name){return Require(args, name)[0];}
// Original:
public static String toStringTree(Tree t) {return toStringTree(t, (List<String>)null);}

// Translation:
public static string ToStringTree(ITree t){return ToStringTree(t, (IList<string>)null);}
// Original:
public String toString() {return "<deleted/>";}

// Translation:
public override string ToString(){return "<deleted/>";}
// Original:
public GetRepoWebhookLogListRequest() {super("cr", "2016-06-07", "GetRepoWebhookLogList", "cr");setUriPattern("/repos/[RepoNamespace]/[RepoName]/webhooks/[WebhookId]/logs");setMethod(MethodType.GET);}

// Translation:
public GetRepoWebhookLogListRequest(): base("cr", "2016-06-07", "GetRepoWebhookLogList", "cr", "openAPI"){UriPattern = "/repos/[RepoNamespace]/[RepoName]/webhooks/[WebhookId]/logs";Method = MethodType.GET;}
// Original:
public GetJobUnlockCodeResult getJobUnlockCode(GetJobUnlockCodeRequest request) {request = beforeClientExecution(request);return executeGetJobUnlockCode(request);}

// Translation:
public virtual GetJobUnlockCodeResponse GetJobUnlockCode(GetJobUnlockCodeRequest request){var options = new InvokeOptions();options.RequestMarshaller = GetJobUnlockCodeRequestMarshaller.Instance;options.ResponseUnmarshaller = GetJobUnlockCodeResponseUnmarshaller.Instance;return Invoke<GetJobUnlockCodeResponse>(request, options);}
// Original:
public RemoveTagsRequest(String resourceId) {setResourceId(resourceId);}

// Translation:
public RemoveTagsRequest(string resourceId){_resourceId = resourceId;}
// Original:
public short getGB2312Id(char ch) {try {byte[] buffer = Character.toString(ch).getBytes("GB2312");if (buffer.length != 2) {return -1;}int b0 = (buffer[0] & 0x0FF) - 161; int b1 = (buffer[1] & 0x0FF) - 161; return (short) (b0 * 94 + b1);} catch (UnsupportedEncodingException e) {throw new RuntimeException(e);}}

// Translation:
public virtual short GetGB2312Id(char ch){try{byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(ch.ToString());if (buffer.Length != 2){return -1;}int b0 = (buffer[0] & 0x0FF) - 161; int b1 = (buffer[1] & 0x0FF) - 161; return (short)(b0 * 94 + b1);}catch (ArgumentException e) {throw new Exception(e.ToString(), e);}}
// Original:
public BatchRefUpdate addCommand(Collection<ReceiveCommand> cmd) {commands.addAll(cmd);return this;}

// Translation:
public virtual NGit.BatchRefUpdate AddCommand(ICollection<ReceiveCommand> cmd){Sharpen.Collections.AddAll(commands, cmd);return this;}
// Original:
public short checkExternSheet(int sheetNumber){return (short)getOrCreateLinkTable().checkExternSheet(sheetNumber);}

// Translation:
public int CheckExternSheet(int sheetNumber){return OrCreateLinkTable.CheckExternSheet(sheetNumber);}
// Original:
@Override public boolean equals(Object object) {return c.equals(object);}

// Translation:
public override bool Equals(object @object){return c.Equals(@object);}