spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

For Looping in C#?


Try like this

    Console.WriteLine(" A " + " B " + "
C ");
    for(int x=1,y=2,z=1;x<=10;x++,y+=2,z+=2)
    {
         Console.WriteLine(x+" " + y +" " + z);
    }
    Console.WriteLine(" Sum ");
    for(int x=1,y=2,z=1;x<=10;x++,y+=2,z+=2)
    {
         Console.WriteLine((x*y+z).ToString());
    }

To get your give formate

Console.WriteLine(" A " + " B " + " C
");
for(int x=1,y=2,z=1;x<=10;x++,y+=2,z+=2)
{

     Console.Write(" "+x);
     if(x<10)
     Console.Write("  "+y);
     else
     Console.Write(" "+y);

     if(y<10)
      Console.Write("  "+z);
     else
      Console.Write(" "+z);
      Console.WriteLine();
}  

OUTPUT

 A  B  C 
 1  2  1
 2  4  3
 3  6  5
 4  8  7
 5  10 9
 6  12 11
 7  14 13
 8  16 15
 9  18 17
 10 20 19

Categories : C#

Related to : For Looping in C#?
PHP - Issues with infinite looping
You should avoid nesting query calls as you do it. Use rather the DOMNodeList obtained at each iteration, with the item method. For instance, instead of writing: foreach ($xpath->query('./following-sibling::div[@class="colmask"]', $e) as $li) { foreach ($xpath->query('//div/h4', $e) as $div) { $state = $div->nodeValue; Write: $result = $xpath->query('./following-siblin

Categories : PHP
Javascript: Looping through an array
I based this answer on what appears that you want to achieve (your second code-block). -1 (often returned by functions/methods whose valid output includes 0) is called a 'sentinel value' and in javascript one catches them using ~: everything that is not -1 will coerce to true. Further explanations as comments in code: (window.Orders=function(){ // our constructor function this.clr();

Categories : Javascript
looping array not working
You're using the identity operator. You're not assigning a value. cost === (cost + parseInt(this.items[i].price)); Should be: cost += parseInt(this.items[i].price); And the rest: var basket = {}; basket.items = [{price:10}, {price:"10"} /*,{price:"nan"}*/]; basket.costCalculate = function () { var cost = 0; for (var i = 0; i < this.items.length; i++) { // Breaks for NaN val

Categories : Javascript
Improving recursive SQL looping
You could use a common table expression for this: WITH Antecedents (ITemID, ParentItemID, Level) AS ( -- Anchor member definition SELECT ItemID, ParentItemID, 0 AS Level FROM Items WHERE ItemID = @StartingID UNION ALL SELECT ItemID, ParentItemID, Antecedents.Level + 1 AS Level FROM Items INNER JOIN Antecedents ON Antecedents.ParentItemID = Items.ItemID ) SELECT

Categories : SQL
for all/for each looping through a Delphi TCollection?
For..in loops are implemented as calls to GetEnumerator and the methods on the variable it returns. The Items property is not an object, but an array property that maps silently to a getter/setter pair, so it can't return an enumerator, but TCollection itself does have a GetEnumerator method. Thus: for mycollectionitem in mycollection do mycollectionitem.setWhatever(); Be aware, though, th

Categories : Delphi
Recently Add
How to call a method in .cs file which was implemented in code behind?
How To Prevent $variables In Restangular Post Request
Windows Phone 8 VoIP SIP Provider
How do we set the AutoCAD layer viewport override values
Load Dependent DLL using reflection
The code is not showing any error but still not displaying data on the datagrid of webform.?
Make an Image that can be flipped over in Unity 4.6
Storing JSON REST response in object
which is more efficient in conditional looping?
WebBrowser control's shortcut keys are not working
C# SQL INSERT not appearing in database table "no errors or exceptions thrown"
c# winfrom treeview class binding
How to Convert string "00h:03m:30s:793ms" to TimeSpan in c#
Calling a parameterized Stored Procedure that returns a value in C#
How to use the SQL statement to transform the data from row record to column record
How to Instantiate Enemy Prefabs Without Knowing the Name
MVC JQuery unobtrusive validation
How to draw at top left of metaFile
How to make Aggregate Root method only accessible for a Domain Event and nothing else.
how to create a list of lists from one list using LINQ?
Ignore user roles in ASP .Net MVC 5 Identity
Xpath Web scrape
add property to interface
How can I make controls added to existing mark-up be automatically hooked up to the code behind?
Too much data in C# windows form combobox, taking 30 sec to show the windows form
Creating a scrolling grid of images using WPF and XAML
PHP equivalent to asp.net routing
LINQ aggregate query
Custom Control won't fill dock correctly
Get ASP.NET Identity Current User In View
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.