CIT304 Chapter 5
CIT304 Chapter 5
Adedoyin I. OYEBADE
[email protected]
Bowen University,
Iwo, Nigeria
May 2, 2023
1 Concatenation of Strings
• This allows chaining of concatenate (+) operations one after
another in a sequence.
class WritinOutConsole
{
static void Main()
{
string age = ”twenty six”;
string text = ”He is ” + age + ” years old.”;
Console.WriteLine(text);
}
}
1 Composite Formatting
class WritinOutConsole
{
static void Main()
{
string name = ”John”;
int age = 18;
string town = ”Seattle”;
Console.Write(”{0} is {1} years old from {2}!”, name, age,
town);
}
}
• user-defined formats
2 Write a program that reads from the console the radius ”r” of a
circle and prints its perimeter and area.
3 Write a program that reads two numbers from the console and
prints the greater of them.