C# Sharp Exercises: Function: Learn, how to create a user define function with parameters
C# Sharp Function: Exercise-2 with Solution
Write a program in C# Sharp to create a user define function with parameters.
Pictorial Presentation:
Sample Solution:
C# Sharp Code:
using System;
public class funcexer2
{
public static void welcome(string name)
{
Console.WriteLine("Welcome friend " + name+" !");
}
public static void HaveAnice()
{
Console.WriteLine("Have a nice day!");
}
public static void Main(string[] args)
{
Console.Write("\n\nSee, how to create an user define function with parameters :\n");
Console.Write("----------------------------------------------------------------\n");
string str1;
Console.Write("Please input a name : ");
str1 = Console.ReadLine();
welcome(str1);
HaveAnice();
}
}
Sample Output:
See, how to create an user define function with parameters : ---------------------------------------------------------------- Please input a name : John Welcome friend John ! Have a nice day!
Flowchart :
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a program in C# Sharp to create a user define function.
Next: Write a program in C# Sharp to create a function for the sum of two numbers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework