Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,
Guys I am new to C# language coding. Any help would be great:
C#
using System;

    class programone
    {
        public static  fun()
        {
            Console.WriteLine("c sharp");
        }
    }

class programtwo
{
    public static void Main()
    {
         Console.WriteLine(" language" );
    }
}
Posted
Updated 4-Mar-11 4:00am
v2

1 solution

Try:
C#
class programtwo
{
    public static void Main()
    {
         programone.fun();   //Add this line.
         Console.WriteLine(" language ");
    }
}
This will execute the method "fun" from class "programone" before it writes the word "language"

It may be worth adding a second line:
C#
class programtwo
{
    public static void Main()
    {
         programone.fun();   
         Console.WriteLine(" language ");
         Console.ReadLine();    //Add this one as well.
    }
}
This will cause the execution to stop until you press the ENTER key: that way you can read what you have written!

Manas Bhardwaj Suggests that you might want the output as a single line, rather than two.

If so, then replace the line:
MIDL
Console.WriteLine("c sharp");
in the "fun" method with:
MIDL
Console.Write("c sharp");
And it will work.

[edit]Answer updated - OriginalGriff[/edit]
 
Share this answer
 
v3
Comments
OriginalGriff 4-Mar-11 10:05am    
I do wish people would tell you what they have changed...:laugh:
Manas Bhardwaj 4-Mar-11 10:23am    
The output of this program would be:

c sharp
language

I don't think that OP wants it in two lines.
OriginalGriff 4-Mar-11 11:21am    
Answer updated
Manas Bhardwaj 4-Mar-11 11:37am    
:)

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