gpt-4-0125-preview· openai
Suzhen/CodeChat
write code on your Console Application with - First Name - Last Name - Contact No -…
- User
write code on your Console Application with
- First Name
- Last Name
- Contact No
- Email Address
- Address
- Assistant
write code on your Console Application with
Certainly! If you're building a simple console application in C# to collect and display user information such as first name, last name, contact number, email address, and physical address, the following is an example code to do just that.
This example makes use of the Console class to interact with the user through the console window. It gathers the required information and then displays it back to the user.
using System;
namespace UserInfoConsoleApp
{
class Program
{
static void Main(string[] args)
{
// Prompt user for their first name and read it from console
Console.WriteLine("Please enter your First Name:");
string firstName = Console.ReadLine();
// Prompt user for their last name and read it from console
Console.WriteLine("Please enter your Last Name:");
string lastName = Console.ReadLine();
// Prompt user for their contact number and read it from console
Console.WriteLine("Please enter your Contact No:");
string contactNo = Console.ReadLine();
// Prompt user for their email address and read it from console
Console.WriteLine("Please enter your Email Address:");
string email = Console.ReadLine();
// Prompt user for their physical address and read it from console
Console.WriteLine("Please enter your Address:");
string address = Console.ReadLine();
// Display the collected information back to the user
Console.WriteLine("\nThank you! Here is the information you entered:");
Console.WriteLine($"First Name: {firstName}");
Console.WriteLine($"Last Name: {lastName}");
Console.WriteLine($"Contact No: {contactNo}");
Console.WriteLine($"Email Address: {email}");
Console.WriteLine($"Address: {address}");
// Wait for the user to press a key before closing
Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
}
}
To run this application:
Program.cs file content with the code snippet above.dotnet run.This application interacts with the user through the console, gathers their personal information, and then echoes that information back to the user.