Skip to content

Instantly share code, notes, and snippets.

@smart-onion
Created July 14, 2025 17:44
Show Gist options
  • Select an option

  • Save smart-onion/0e5f28aef47b7240aecb34ef096c7e5d to your computer and use it in GitHub Desktop.

Select an option

Save smart-onion/0e5f28aef47b7240aecb34ef096c7e5d to your computer and use it in GitHub Desktop.
asp.net lesson1
using System.Text;
var builder = WebApplication.CreateBuilder(args);
var persons = new List<Person>
{
new Person("Jon", "Smith", "jon@mail.com", 20, "1234567890"),
new Person("Alex", "Mart", "Alex@mail.com", 18, "1234567890"),
new Person("May", "Doe", "May@mail.com", 20, "1234567890"),
new Person("Jon", "Smith", "Jon@mail.com", 20, "1234567890"),
};
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.UseStaticFiles();
app.Run(async (context) =>
{
var response = context.Response;
response.ContentType = "text/html";
var strb = new StringBuilder();
strb.AppendLine("""
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Age</th>
<th>Phone number</th>
</tr>
""");
persons.ForEach(person => strb.AppendLine($"""
<tr>
<td>{person.FirstName}</td>
<td>{person.LastName}</td>
<td>{person.Email}</td>
<td>{person.Age}</td>
<td>{person.PhoneNumber}</td>
</tr>
"""));
strb.AppendLine("</table>");
await response.WriteAsync(strb.ToString());
});
app.Run();
record Person(string FirstName, string LastName, string Email, int Age, string PhoneNumber);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment