2017-08-10 7 views
0

に変換しています。こんにちは、イメージ内のテキストを認識するためのVBプログラムに基づくC#プログラムを作成しています。しかし、私はこの行のC#の同等を把握することができるように見えることはできません。VBプログラムの特定の行をC#

listOfContoursWithData.Sort(Function(oneContourWithData, otherContourWithData) oneContourWithData.boundingRect.X.CompareTo(otherContourWithData.boundingRect.X)) 

これはlistOfContoursWithDataはのインスタンスであるContourWithDataクラスです:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Emgu.CV.Util; 

namespace TrainAndTest 
{ 
    public class ContourWithData 
    { 
     const int MIN_CONTOUR_AREA = 100; 

     public VectorOfPoint contour; // contour 
     public System.Drawing.Rectangle boundingRect; // bounding rect for contour 
     public double dblArea; // area of contour 

     public bool checkIfContourIsValid(){ 
     if ((dblArea < MIN_CONTOUR_AREA)) 
      return false; 
     else 
      return true; 
    } 
} 
+0

'listOfContoursWithData'は' List 'ですか? –

答えて

2

あなたが使用することができますラムダ式:

listOfContoursWithData.Sort((oneContourWithData, otherContourWithData) => 
           oneContourWithData.boundingRect.X.CompareTo(otherContourWithData.boundingRect.X)); 

List<ContourWithData>.Sort()メソッドは、パラメータとしてComparison<ContourWithData>を取ります。これは2つのContourWithDataインスタンスを入力としてデリゲートし、intを返します。

+0

ありがとう、これは私をとても助けました:) –

関連する問題