Click here to Skip to main content
15,889,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code PLZ TELL ME WHERE I AM WRONG
Actually I want this type of output:

VB
Function 1 exectuded 0
Function 1 exectuted 1
Function 1 exectuted 2
Function 1 exectuted 3
Function 1 exectuted 4
Function 1 exectuted 5

Function 2 exectuted 0
Function 2 exectuted 1
Function 2 exectuted 2
Function 2 exectuted 3
Function 2 exectuted 4
Function 2 exectuted 5


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace thread_example2
{
    class Program
    {
        static void Main(string[] args)
        {
            function1();
            function2();


        }
        static void function1()
        {
            for (int i = 0; i >= 5; i++)
            {
                Console.WriteLine("Function 1 Executed" + i.ToString());
            }

        }
        static void function2()
        {
            for (int i = 0; i >= 5; i++)
            {
                Console.WriteLine("Function 2 Exwcuted" + i.ToString());

            }

        }

    }
}
Posted
Updated 30-Dec-14 2:04am
v2
Comments
OriginalGriff 30-Dec-14 7:55am    
How would we know?
We don't know what it is intended to do, and you don't tell us.
We need to know what it is doing that you didn't expect, or not doing that you did! :laugh:
Use the "Improve question" widget to edit your question and provide better information.
Er. Dinesh Sharma 30-Dec-14 7:58am    
In main method add Console.ReadLine();
Member 11132163 30-Dec-14 8:06am    
I tried it but it is showing blank screen

You have >= instead of <= in your For statements.

This works:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            function1();
            function2();
            String line = Console.ReadLine();


        }
        static void function1()
        {
            for (int i = 0; i <= 5; i++)
            {
                Console.WriteLine("Function 1 Executed" + i.ToString());
            }

        }
        static void function2()
        {
            for (int i = 0; i <= 5; i++)
            {
                Console.WriteLine("Function 2 Executed" + i.ToString());

            }

        }

    }
}
 
Share this answer
 
v2
The condition given in for loop is wrong :-
It should be :- for (int i = 0; i <= 5; i++)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900