Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1.HTML
- {
- class HTMLManager
- {
- public string CreateHTML(string templateHTML, string[] userNameArray)
- {
- string html = File.ReadAllText(templateHTML);
- html = html.Replace("{USERARRAY}", UserHTML(userNameArray));
- html = html.Replace("{USERSUM}", userNameArray.Length.ToString());
- //File.WriteAllText("test.txt", text);
- Console.WriteLine("HTML Composed");
- return html;
- }
- private string UserHTML(string[] userNameArray)
- {
- string userHTML = "";
- List<string> userNames = new List<string>();
- for(int i = 0; i < userNameArray.Length; i++)
- {
- userNames.Add("<tr>" +
- "<td>" + userNameArray[i] + "</td>" +
- "<td>" + userNameArray[i] + "</td>" +
- "</tr>" + "\n");
- }
- userHTML = string.Join("", userNames);
- Console.WriteLine("UserHTML Complete");
- return userHTML;
- }
- }
- }
Add Comment
Please, Sign In to add comment