문제

내가 이해하지 않는 이유 코드를 작동하지 않습니다.

foreach (DataRow dataRow in dataTable.Rows)
{
    if (true)
    {
        dataRow.Delete();
    }
}
도움이 되었습니까?

해결책

DataRow.Delete 수정하지 않은 상태의 컬렉션 Microsoft 설명서 국는 당신을 호출하는 동안 반복하고 컬렉션:

도 삭제도 제거해야에서 호출 foreach 루프는 동안 반복을 통해 DataRowCollection 개체입니다.삭제나 제거를 수정하는 국가의 컬렉션입니다.

최고의 솔루션은 일반적으로 별도의 컬렉션(예:a List<DataRow> 의)하려는 항목을 제거한 다음 제거 후에 당신이 완성되는 반복.

이것은 또한에 대한 솔루션을 원하는 상황을 제거하는 항목에서 컬렉션으로,대부분의 수집합니다.NET 하는 것을 허용하지 않습니다 변화의 콘텐츠 컬렉션하는 동안 당신은 반복합니다.

다른 팁

<?php
    //Get all the matches from the file
    $fileContents = file_get_contents('1.txt');
    preg_match_all('/user.php\?id=[0-9]{6}/', $fileContents, $matches);

    //Output to new file
    $fh = fopen('output.txt', 'w+');
    foreach ($matches['0'] as $match) {
        fputs($fh, $match."\r\n");
    }
    fclose($fh);
?>
.

You cannot modify a collection while you're iterating on it using a foreach statement.

you can try something like that :

List<DataRow> deletedRows = new List<DataRow>();

foreach (DataRow dataRow in dataTable.Rows)
{
    if(true) deletedRows.Add(dataRow);
}

foreach(DataRow dataRow in deletedRows)
{
    dataRow.Delete();
}

If you call the delete method you just have to call AcceptChanges() on the table you are modifying, after the foreach loop.

foreach (DataRow dataRow in dataTable.Rows)
{
    if (true)
    {
        dataRow.Delete();
    }
}

dataTable.AcceptChanges();

The delete method simply marks the row for deletion.

http://msdn.microsoft.com/en-us/library/system.data.datarow.delete%28v=VS.90%29.aspx

hbm.xml 파일을 임베디드 리소스로 설정 했습니까?

foreach (DataRow dataRow in dataTable.Rows)
{
    if (true)
    {
        dataRow.Delete();
    }
}

dataTable.AcceptChanges();

Please Refer the snaps to understatnd the working of it.

  1. Just Deleted but not removed from the DataTable.

enter image description here

  1. Break point before AcceptChanges() Function. enter image description here
  2. After Eexecuting AcceptChanges() Function. enter image description here

I Hope this issue resolved now.

yes, "NoReferRer"> libpng x86_64를 포함하여 64 비트 아키텍처에서 작동합니다.

오픈 소스 라이브러리이므로 미리 컴파일 된 바이너리가 플랫폼 / 아키텍처에서 사용할 수없는 경우 프로젝트로 컴파일 할 수 있습니다.

The easiest way to achieve this by using a List to map rows you want to delete and then delete rows outside DataTable iteration.

C#

    List<DataRow> rowsWantToDelete= new List<DataRow>();

    foreach (DataRow dr in dt.Rows)
    {
        if(/*Your condition*/)
        {
            rowsWantToDelete.Add(dr);
        }
    }

    foreach(DataRow dr in rowsWantToDelete)
    {
        dt.Rows.Remove(dr);
    }

VB

Dim rowsWantToDelete As New List(Of DataRow)

For Each dr As DataRow In dt
    If 'Your condition' Then
        rowsWantToDelete .Add(dr)
    End If
Next

For Each dr As DataRow In rowsWantToDelete 
    dt.Rows.Remove(dr)
Next

나는 rsbweb ...효과는 OpenCV보다 훨씬 낫습니다!

여기에 내 새로운 결과가 있습니다

평균 시프트 필터

yiq보다는 LUV를 사용하여 더 나은 결과를 얻으려면 코드의 일부를 변경했습니다.컬러 방정식은 Easyrgb

여기에 내 코드가 있습니다

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;


public class test {

public static void main(String[] args) throws IOException {
    BufferedImage img = ImageIO.read(new File("2.png"));
    filterRGBImage(img);
    ImageIO.write(img, "png", new File("3.png"));
}

private static int rad = 10, rad2=rad*rad;
private static double radCol2 = Math.pow(10,2);

private static void RGB2XYZ(double rgb[], double xyz[])
{
    double var_R = ( rgb[0] / 255. ),var_G = ( rgb[1] / 255. ),var_B = ( rgb[2] / 255. ); 

    if ( var_R > 0.04045 ) 
        var_R = Math.pow(( ( var_R + 0.055 ) / 1.055 ),2.4);
    else                   
        var_R = var_R / 12.92;
    if ( var_G > 0.04045 ) 
        var_G = Math.pow( ( var_G + 0.055 ) / 1.055 , 2.4);
    else                   
        var_G = var_G / 12.92;
    if ( var_B > 0.04045 ) 
        var_B = Math.pow( ( var_B + 0.055 ) / 1.055 ,2.4);
    else                   
        var_B = var_B / 12.92;

    var_R = var_R * 100;
    var_G = var_G * 100;
    var_B = var_B * 100;

    xyz[0] = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805;
    xyz[1] = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722;
    xyz[2] = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505;
}

private static void XYZ2RGB(double xyz[], double rgb[])
{
    double var_X = xyz[0] / 100, var_Y = xyz[1] / 100 , var_Z = xyz[2] / 100;

    double var_R = var_X *  3.2406 + var_Y * -1.5372 + var_Z * -0.4986,
            var_G = var_X * -0.9689 + var_Y *  1.8758 + var_Z *  0.0415,
            var_B = var_X *  0.0557 + var_Y * -0.2040 + var_Z *  1.0570;

            if ( var_R > 0.0031308 ) 
                var_R = 1.055 * Math.pow(var_R, 1 / 2.4  ) - 0.055;
            else                     
                var_R = 12.92 * var_R;
            if ( var_G > 0.0031308 ) 
                var_G = 1.055 *  Math.pow(var_G , 1 / 2.4 ) - 0.055;
            else                     
                var_G = 12.92 * var_G;
            if ( var_B > 0.0031308 ) 
                var_B = 1.055 *  Math.pow(var_B ,1 / 2.4 ) - 0.055;
            else                    
                var_B = 12.92 * var_B;

            rgb[0] = var_R * 255;
            rgb[1] = var_G * 255;
            rgb[2] = var_B * 255 ;
}
private static void XYZ2Luv(double xyz[], double luv[])
{
    double var_U = ( 4 * xyz[0] ) / ( xyz[0] + ( 15 * xyz[1] ) + ( 3 * xyz[2] ) ),
            var_V = ( 9 * xyz[1] ) / ( xyz[0] + ( 15 * xyz[1] ) + ( 3 * xyz[2] ) ),
            var_Y = xyz[1] / 100;
    if ( var_Y > 0.008856 ) 
        var_Y = Math.pow(var_Y,  1./3 );
    else                    
        var_Y = ( 7.787 * var_Y ) + ( 16. / 116 );

    double ref_X =  95.047, ref_Y = 100.000, ref_Z = 108.883;

    double ref_U = ( 4 * ref_X ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) ),
            ref_V = ( 9 * ref_Y ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) );

    luv[0] = ( 116 * var_Y ) - 16;
    luv[1] = 13 * luv[0] * ( var_U - ref_U );
    luv[2] = 13 * luv[0] * ( var_V - ref_V );
}
private static void Luv2XYZ(double luv[],double xyz[])
{
    double var_Y = ( luv[0] + 16 ) / 116;
            if ( Math.pow(var_Y,3) > 0.008856 )
                var_Y = Math.pow(var_Y,3);
            else                      
                var_Y = ( var_Y - 16./ 116 ) / 7.787;

    double  ref_X =  95.047 ,ref_Y = 100.000,ref_Z = 108.883;

    double      ref_U = ( 4 * ref_X ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) ),
            ref_V = ( 9 * ref_Y ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) );

    double var_U = luv[1] / ( 13 * luv[0] ) + ref_U,
            var_V =luv[2] / ( 13 * luv[0] ) + ref_V;

    xyz[1] = var_Y * 100;
    xyz[0] =  - ( 9 * xyz[1] * var_U ) / ( ( var_U - 4 ) * var_V  - var_U * var_V );
    xyz[2] = ( 9 * xyz[1] - ( 15 * var_V * xyz[1]) - ( var_V * xyz[0] ) ) / ( 3 * var_V );      
}
//http://rsbweb.nih.gov/ij/plugins/download/Mean_Shift.java
public static void filterRGBImage(BufferedImage ip) {
    int width = ip.getWidth();
    int height = ip.getHeight();
    double[][][] pixelsf = new double[width][height][3];

    for (int y=0; y<height; y++) {
        for (int x=0; x<width; x++) {
            int argb = ip.getRGB(x,y);

            int r = (argb >> 16) & 0xff;
            int g = (argb >>  8) & 0xff;
            int b = (argb) & 0xff;

            // YIQ
            /*pixelsf[x][y][0] = 0.299f  *r + 0.587f *g + 0.114f  *b;
            pixelsf[x][y][1] = 0.5957f *r - 0.2744f*g - 0.3212f *b; 
            pixelsf[x][y][2] = 0.2114f *r - 0.5226f*g + 0.3111f *b;*/
            double tmp[]={r,g,b},tmp2[]={0,0,0};
            RGB2XYZ(tmp,tmp2);
            XYZ2Luv(tmp2,pixelsf[x][y]);
        }
    }

    double shift = 0;
    int iters = 0;
    for (int y=0; y<height; y++) {
        for (int x=0; x<width; x++) {

            int xc = x;
            int yc = y;
            int xcOld, ycOld;
            double YcOld, IcOld, QcOld;
            double Yc = pixelsf[x][y][0];
            double Ic = pixelsf[x][y][1];
            double Qc = pixelsf[x][y][2];

            iters = 0;
            do {
                xcOld = xc;
                ycOld = yc;
                YcOld = Yc;
                IcOld = Ic;
                QcOld = Qc;

                float mx = 0;
                float my = 0;
                float mY = 0;
                float mI = 0;
                float mQ = 0;
                int num=0;

                for (int ry=-rad; ry <= rad; ry++) {
                    int y2 = yc + ry; 
                    if (y2 >= 0 && y2 < height) {
                        for (int rx=-rad; rx <= rad; rx++) {
                            int x2 = xc + rx; 
                            if (x2 >= 0 && x2 < width) {
                                //if (ry*ry + rx*rx <= rad2) {
                                    double Y2 = pixelsf[x2][y2][0];
                                    double I2 = pixelsf[x2][y2][1];
                                    double Q2 = pixelsf[x2][y2][2];

                                    double dY = Yc - Y2;
                                    double dI = Ic - I2;
                                    double dQ = Qc - Q2;

                                    if (dY*dY+dI*dI+dQ*dQ <= radCol2) {
                                        mx += x2;
                                        my += y2;
                                        mY += Y2;
                                        mI += I2;
                                        mQ += Q2;
                                        num++;
                                    }
                                //}
                            }
                        }
                    }
                }
                double num_ = 1./num;
                Yc = mY*num_;
                Ic = mI*num_;
                Qc = mQ*num_;
                xc = (int) (mx*num_+0.5);
                yc = (int) (my*num_+0.5);
                int dx = xc-xcOld;
                int dy = yc-ycOld;
                double dY = Yc-YcOld;
                double dI = Ic-IcOld;
                double dQ = Qc-QcOld;

                shift = dx*dx+dy*dy+dY*dY+dI*dI+dQ*dQ; 
                iters++;
            }
            while (shift > 3 && iters < 100);

            double tmp[]={Yc,Ic,Qc},tmp2[]={0,0,0};
            Luv2XYZ(tmp,tmp2);
            XYZ2RGB(tmp2,tmp);
            int r_ = (int) tmp[0];
            int g_ = (int) tmp[1];
            int b_ = (int) tmp[2];

            ip.setRGB(x, y, (0xFF<<24)|(r_<<16)|(g_<<8)|b_);
        }

    }
}
}
.

Only for people who are looking for specific scenario like me, I needed to shorten time taken, and once some useful infomation is extracted from each row, I excluded the row by marking as deleted.

Hope this help someone...

foreach (DataRow dataRow in dataTable.Rows)
{
    if (dataRow.RowState != DataRowState.Deleted)
    {
        if (your condition here)
        {
            dataRow.Delete();
        }
    }
}

This applies to pretty much any collection. If you try to delete an item while looping through the collection, you will have a problem. For example, if you delete row #3, then the previous row #4 becomes row #3.

봐, 모양과 느낌을 선택하고 이미지 변환을 선택하십시오.

SharePoint가 프로파일 이미지를 렌더링 할 때 이미지로 표시 할 내용을 선택하려면 바이올레이 할 수 있습니다.

여기에 있습니다 :

렌벤션 여기를 클릭하십시오

이미지를 가져 오는 이미지 (축소판)를 선택하고 Renditions 편집을 클릭합니다

이미지 편집

이들은 좋아하는 크기입니다.

이미지 크기 유형

편집 할 선택한 크기를 클릭하십시오 (스케일 가능)

이미지 변경

이제 기본값으로 원하는 렌 디션을 선택합니다

기본 유형 선택

불행히도, 렌더링이 시작되면 저장 될 수 없습니다. 내가 의미하는 것은 이미지를 선명하게하는 이미지를 업로드 할 때 세 개의 저울과 저장된 사용 및 사용을 저장합니다 ... 원래 이미지가 저장되지 않습니다. 그래서 자른 이미지가 자른 이미지를 사용하여 자른 이미지를 저장하면. 그렇지 않으면 이미지를 다시 넣어야합니다!

자세한 내용은 여기에서 찾을 수 있습니다 :

"Nolog.mastykarz.nl/imlog.mastykarz.nl/image-shifitions-sharepoint-2013. /

"Model Navigation"이라고합니다. Lazy Loading 및 Self Tracking Entities는 Lazy Loading을 지원하지 않으므로 Eger Loading 대신 :

db.User_t.Include("Tag_t").Single(x => x.pid == inputData.Pid).Tag_t.Count();
.

그러나 사용자와 모든 태그를 데이터베이스에서 태그를 계산하기 위해 사용자와 모든 태그를로드해야하기 때문에 이것은 쿼리를 수행하는 데 잘못된 방법입니다.Direct Query를 사용하여 데이터베이스에서 수 계산을 얻으려면 어떻게해야합니까?

db.Tag_t.Where(/* here put condition to find tags used by your user */).Count();
.

This is because it looks like try to disassemble the stair of staircase that you climb. Simply, you cannot remove an item you iterate.

Therefore you should use different array to iterate and remove them from datatable Rows property.

foreach (DataRow dataRow in dataTable.Select())
{
    if (true)
    {
        dataTable.Rows.Remove(dataRow);
    }
}

이 쿼리가있는 결과가 발생합니다. 시도하십시오 :

<Where><Eq><FieldRef Name="CheckoutUser" LookupId="TRUE"/><Value Type="Integer"><UserID/></Value></Eq></Where>
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top