Skip to main content

C#: Program #23 (While Loop)

using System;

namespace While_Loop
{
    class Program
    {
        static void Main(string[] args)
        {
            int i=1;

            while (i < 10)
            {
                if (i%2==0)
                {
                    i++;
                   continue;
                }

                Console.WriteLine("Odd number found:{0}",i);

                i++;


            }
            Console.ReadKey();
        }
    }
}

Comments

Popular posts from this blog

C#: Program #38 (Oop4)

using System; namespace Oop_Inheritance_ {     class Program     {         static void Main(string[] args)         {             Animal obj=new Animal("Balto","Howl");             obj.setAnimalIdInfo(1,"Balto");             obj.getAnimalInfo();             Dog obj2 = new Dog("Hachico", "howl", "Grrrr");             obj2.Sound="Woof Woof";             obj2.setAnimalIdInfo(5, "Hachico");             obj2.getAnimalInfo();             Console.WriteLine(obj2.Name);             Console.WriteLine(obj2.Sound);             Animal sloth = new Dog("Simon", "bark", "woof");             sloth.M...

C#: Program #48 (Generic Struct)

using System; using System.Linq; namespace Generics1 {     class Program     {         static void Main(string[] args)         {             Rectangle<string> myobj = new Rectangle<string>("8", "6");             Console.WriteLine(myobj.Area());             Console.ReadKey();         }         public struct Rectangle<T>         {             private T length,width;             public T Width { get { return width; } set { width = value; } }             public T Length { get { return length; } set { length = value; } }         public Rectangle(T w, T l)         {             width = w; ...