Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Saturday, September 25, 2010

I saw some interesting code:

for (; contours != null; contours = contours.HNext)
{
Contour<Point> approxContour = contours.ApproxPoly(contours.Perimeter * 0.02, contours.Storage);
img.Draw(approxContour, new Bgr(1, 1, 251), 2);
}

I’d never seen the initial part of the for statement missing so I played:

class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 5; i++) // normal usage
{
Console.WriteLine("i count is {0}", i);
}

int k = 1;
for (; k<=5; k++) // missing first bit
{
Console.WriteLine("k count is {0}", k);
}

int m = 1;
for (; m <= 5;) // missing last bit too
{
Console.WriteLine("m count is {0}", m);
m++;
}

for (; ; ) // infinite loop, never breaks out
{

}



Contour contA = new Contour { x = 10, y = 20 };
Contour contB = new Contour { x = 50, y = 60 };
Contour contC = new Contour { x = 90, y = 100 };

List<Contour> listOfContours = new List<Contour>();
listOfContours.Add(contA); // better way to add to a collection?
listOfContours.Add(contB);
listOfContours.Add(contC);

foreach (Contour contour in listOfContours)
{
Console.WriteLine("x is {0}", contour.x.ToString());
Console.WriteLine("y is {0}", contour.y.ToString());
Console.WriteLine();
}

int j = 0;
while (j < 5)
{
Console.WriteLine("While loop counter is {0}", j.ToString());
j++;
}
}
}

class Contour
{
public int x;
public int y;
//public int x { get; set; }
//public int y { get; set; }
}


All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview