UriBuilder builder = new UriBuilder("https://www.example.com"); builder.AppendQueryArgument("name", "John"); builder.AppendQueryArgument("age", "30"); Uri result = builder.Uri;
string baseUrl = "https://www.example.com"; string[] colors = { "red", "green", "blue" }; UriBuilder builder = new UriBuilder(baseUrl); foreach (string color in colors) { builder.AppendQueryArgument("color", color); } Uri result = builder.Uri;In this example, we create an array of colors and loop through each color to add them as query parameters to the Uri. The resulting Uri object will have query parameters for each color in the array. This method is part of the System.Net package library in C#.