Hot File

How to C# Continue Statement

View: 367    Dowload: 0   Comment: 0   Post by: hanhga  
Author: none   Category: C / C++ / MFC   Fields: Other

0 point/2 review File has been tested

continue statement skips or exits the current execution of a loop by given condition and keep execution continue for its next iteration unlike break statement it does not exit or terminate from loops, it terminates only its current execution

Introduction

C# continue statement works same as break statement.

It can be used in for, foreach, while and do while loop.

continue statement skips or exits the current execution of a loop by given condition and keep execution continue for its next iteration unlike break statement it does not exit or terminate from loops, it terminates only its current execution

Example – 1, using continue statement with for loop:

using System;
namespace csharpBasic
{
    // Start class definition / declaration.
    class Program
    {
        // Static main method void type declaration.
        static void Main(string[] args)
        {
            // for loop initializing.
            for (int countNumber = 1; countNumber <= 10; countNumber++)
            { // for loop is started.
                 
                // if condition.
                if (countNumber == 6)
                    continue; // continue statement.
 
                // Print countNumber variable.
                Console.WriteLine("Number: {0}", countNumber);
 
            } // End of for loop.
 
            Console.ReadKey();
 
        } // End of main method definition. 
    } // End of class. 
 
    /*
    The Output will be:
    Number: 1
    Number: 2
    Number: 3
    Number: 4
    Number: 5
    Number: 7
    Number: 8
    Number: 9
    Number: 10
  */
}

Example – 2, using continue statement with foreach loop.

using System;
namespace csharpBasic
{
    // Start class definition / declaration.
    class Program
    {
        // Static main method void type declaration.
        static void Main(string[] args)
        {
            // String type array initialization.
            string[] pLanguages = { "C#", "Php", "Asp.NET", "Jquery" , "Css" , "Html" , "Xml" };
 
            // foreach loop declaration.
            foreach (string show in pLanguages)
            { // foreach loop is started.
 
                // if condition checking.
                if (show == "Php" || show == "Jquery")
                    continue; // continue statement.
 
                // Print show variable.
                Console.WriteLine(show);
 
            } // End of foreach loop.
 
            Console.ReadKey();
 
        } // End of main method definition. 
    } // End of class. 
 
    /*
    The Output will be:
    C#
    Asp.NET
    Css
    Html
    Xml
     
  */
}

How to C# Continue Statement

How to C# Continue Statement Posted on 09-09-2016  continue statement skips or exits the current execution of a loop by given condition and keep execution continue for its next iteration unlike break statement it does not exit or terminate from loops, it terminates only its current execution 5/10 367

Comment:

To comment you must be logged in members.

Files with category

  • How to Swap Two Numbers using Call by Reference in C

    View: 505    Download: 0   Comment: 0   Author: none  

    How to Swap Two Numbers using Call by Reference in C

    Category: C / C++ / MFC
    Fields: Other

    0/0 review
    How to swap two numbers using call by reference in C , C++. In the interviews interviewer generally asked the difference between call by reference and call by value

  • How to Print Fibonacci Series using Recursion in C, C++

    View: 505    Download: 0   Comment: 0   Author: none  

    How to Print Fibonacci Series using Recursion in C, C++

    Category: C / C++ / MFC
    Fields: Other

    2.25/2 review
    Write a program to print Fibonacci Series using recursion. Fibonacci series is a very important program in terms of interviews. To make this program little tough interviewer ask to write a fibonacci series code using recursion.

  • How to Implicitly Typed Arrays In C#

    View: 561    Download: 0   Comment: 0   Author: none  

    How to Implicitly Typed Arrays In C#

    Category: C / C++ / MFC
    Fields: Other

    0/2 review
    When we initialize these type of arrays with any data type, the compiler convert these arrays into that data type at compile time.

  • How to C# Static vs Instance Methods As Event Handlers

    View: 401    Download: 0   Comment: 0   Author: none  

    How to C# Static vs Instance Methods As Event Handlers

    Category: C / C++ / MFC
    Fields: Other

    0/0 review
    Both static and instance methods can be used as event handlers in C#

  • Build Pass By Reference To Method In C#

    View: 546    Download: 0   Comment: 0   Author: none  

    Build Pass By Reference To Method In C#

    Category: C / C++ / MFC
    Fields: Other

    0/4 review
    Like value types such as int, double, char etc. We can also pass a reference variable to the method in C# as its parameter which allows us to pass an object to the method and it is called pass by reference to method in C#.

  • How to C# Continue Statement

    View: 367    Download: 0   Comment: 0   Author: none  

    How to C# Continue Statement

    Category: C / C++ / MFC
    Fields: Other

    0/2 review
    continue statement skips or exits the current execution of a loop by given condition and keep execution continue for its next iteration unlike break statement it does not exit or terminate from loops, it terminates only its current execution

  • How to Single Dimensional Arrays In C#

    View: 318    Download: 0   Comment: 0   Author: none  

    How to Single Dimensional Arrays In C#

    Category: C / C++ / MFC
    Fields: Other

    0/2 review
    Single Dimensional Arrays in C# store each individual element at their single dimension, position or a specific location, that location is called an array index. Each index describes the position of each element within an array. Each element in an...

  • Build C# Multilevel Inheritance

    View: 347    Download: 0   Comment: 0   Author: none  

    Build C# Multilevel Inheritance

    Category: C / C++ / MFC
    Fields: Other

    2.5/2 review
    C# supports multilevel inheritance, suppose we have four classes A, B, C and D. Class A can inherit to B, B to C and C can inherit to D and so on now class D has all public members of class A, B and C include its own.

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd