Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
The console is a window in the operating system where users may enter text such as a "hello world" string using the computer keyboard in the new or same line and view text output from the computer terminal to interact with the system or a text-based console application. For instance, under the Windows operating system, MS-DOS instructions may be entered into a console known as the Command Prompt window. Applications that read and write characters to the console are supported fundamentally by the Console class. In this article, we are going to use the WriteLine method within static void main in C#.
The console window may be made to show a line of text followed by a newline by using the WriteLine() function. This function is a part of the Console output class, which is a component of the System namespace and offers functions for working with the standard error, input value, and output streams.
Console.WriteLine(); // console line output
Console.WriteLine(string value); // write value
Console.WriteLine(string format, params object [] args);
Console.WriteLine(); // console line output
Console.WriteLine(string value); // write value
Console.WriteLine(string format, params object [] args);
Console.WriteLine() ' console line output
Console.WriteLine(String value) ' write value
Console.WriteLine(String format, params Object () args)
In C#, concatenation is the process of joining variables or strings into a single string. Concatenation may be utilized with Console. To see concatenated texts or a combination of strings and variables in the console, use WriteLine().
Here's an example using Console to show concatenation.
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
String Name = "Jack";
// Example for concatenating strings and variables using the + operator
Console.WriteLine("Hello " + Name);
// Using string interpolation to concatenate strings and variables
Console.WriteLine($"Hello {Name}");
// Using placeholders and formatting to concatenate strings and variables on same line
Console.Write("Hello {0}", Name);
}
}
}
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
String Name = "Jack";
// Example for concatenating strings and variables using the + operator
Console.WriteLine("Hello " + Name);
// Using string interpolation to concatenate strings and variables
Console.WriteLine($"Hello {Name}");
// Using placeholders and formatting to concatenate strings and variables on same line
Console.Write("Hello {0}", Name);
}
}
}
Namespace ConsoleApp1
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim Name As String = "Jack"
' Example for concatenating strings and variables using the + operator
Console.WriteLine("Hello " & Name)
' Using string interpolation to concatenate strings and variables
Console.WriteLine($"Hello {Name}")
' Using placeholders and formatting to concatenate strings and variables on same line
Console.Write("Hello {0}", Name)
End Sub
End Class
End Namespace
In the above example:
A crucial C# function for console-based input/output tasks is WriteLine(). It is a flexible tool for interaction and communication within console programs because of its capacity to handle several data kinds, apply formatting, and output text or values to the console window.
Obtain the IronPDF Library Installation Guide library; it is necessary for the next patch. Enter the subsequent code into the Package Manager to perform this:
Install-Package IronPdf
As an alternative, you may look for the package "IronPDF" using the NuGet Package Manager. This list of all the NuGet packages related to IronPDF allows us to select and download the required package.
The sample code demonstrates how to use the string interpolation function to produce a PDF and display the process status with the WriteLine method. Format strings and alignment specifiers can be concatenated for a single interpolation statement.
using IronPdf;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
int x = 25;
var outputstr = $@"square of <b>{x}</b> is <b>{Math.Sqrt(x)}</b>";
Console.WriteLine($"Ironpdf Process started at {DateTime.Now.ToString("hh:mm:ss:ffff")}");
var pdfcreate = ChromePdfRenderer.StaticRenderHtmlAsPdf(outputstr);
pdfcreate.SaveAs("demo.pdf");
Console.WriteLine($"Ironpdf Process End at {DateTime.Now.ToString("hh:mm:ss:ffff")}");
}
}
}
using IronPdf;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
int x = 25;
var outputstr = $@"square of <b>{x}</b> is <b>{Math.Sqrt(x)}</b>";
Console.WriteLine($"Ironpdf Process started at {DateTime.Now.ToString("hh:mm:ss:ffff")}");
var pdfcreate = ChromePdfRenderer.StaticRenderHtmlAsPdf(outputstr);
pdfcreate.SaveAs("demo.pdf");
Console.WriteLine($"Ironpdf Process End at {DateTime.Now.ToString("hh:mm:ss:ffff")}");
}
}
}
Imports IronPdf
Namespace ConsoleApp1
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim x As Integer = 25
Dim outputstr = $"square of <b>{x}</b> is <b>{Math.Sqrt(x)}</b>"
Console.WriteLine($"Ironpdf Process started at {DateTime.Now.ToString("hh:mm:ss:ffff")}")
Dim pdfcreate = ChromePdfRenderer.StaticRenderHtmlAsPdf(outputstr)
pdfcreate.SaveAs("demo.pdf")
Console.WriteLine($"Ironpdf Process End at {DateTime.Now.ToString("hh:mm:ss:ffff")}")
End Sub
End Class
End Namespace
In the above example, we are creating the PDF file. We are monitoring the process status with the help of the write method print values of the process started time by converting with the help of the ToString method.
Console Output:
PDF Result:
To read more about the IronPDF, refer to the IronPDF Documentation.
In conclusion, the WriteLine function in C# is a vital tool for developers as it is key to the process of writing data objects to the console. Complex output patterns, formatted texts, and a variety of data kinds may all be shown because of their flexibility and simplicity. WriteLine offers a simple way to communicate in the terminal environment, which makes debugging, testing, and user interaction easier.
The IronPDF price starts at a $749 Lite package that includes a permanent license, upgrade options, one year of software maintenance, and a thirty-day money-back guarantee. During the watermarked trial period, users can assess the product in real-world application scenarios for thirty days. To find out more about IronPDF's price, licensing, and trial version, visit the IronPDF Licensing Page. To learn more about Iron Software products, explore Iron Software's Product Overview.
9 .NET API products for your office documents