Question: I have the following C# code that Creates a Web Service: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace WebService { ///

I have the following C# code that Creates a Web Service:

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services;

namespace WebService { ///

/// Summary description for UltimateGamingPC /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class UltimateGamingPC : System.Web.Services.WebService {

public struct ProductDetails { public int ProductCode; public string ProductTitle; public string Description; public double Price; }

private ProductDetails Products;

public UltimateGamingPC() { Products.ProductCode = 0; Products.ProductTitle = ""; Products.Description = ""; Products.Price = 0; }

private void AssignValues(int ProductCode) {

Products.ProductCode = ProductCode;

if (ProductCode == 1) { Products.ProductTitle = "UG Hunter"; Products.Description = "Intel I7/3.4GHZ, 8GB RAM, 32GB SSD, 1TB HHD, Gigabyte GeForce GT710"; Products.Price = 1999.00; } else if (ProductCode == 2) { Products.ProductTitle = "UG Predator"; Products.Description = "Intel I7/4GHZ, 16GB RAM, 128GB SSD, 2TB HHD, Gigabyte GeForce GT730"; Products.Price = 2499.00; } else if (ProductCode == 3) { Products.ProductTitle = "UG Beast"; Products.Description = "Intel I7/4GHZ, 32GB RAM, 256GB SSD, 2TB HHD, Gigabyte GeForce GT750"; Products.Price = 2999.00; } else { Products.ProductTitle = "Product not found"; Products.Description = ""; Products.Price = 0; } }

[WebMethod(Description = "This method call will get the product title, description and the price for a given product code.", EnableSession = false)] public ProductDetails GetProductDetails(int ProductCode) { AssignValues(ProductCode); ProductDetails RequestedProductDetails = new ProductDetails(); RequestedProductDetails.ProductCode = Products.ProductCode; RequestedProductDetails.ProductTitle = Products.ProductTitle; RequestedProductDetails.Description = Products.Description; RequestedProductDetails.Price = Products.Price; return RequestedProductDetails; }

The problem I have is that the ProductCode that I have to display for this task needs to be "UG1" or "UG2" or "UG3" instead of just 1 or 2 or 3. I am not sure how I am to combine the string and int together for the combined code to appear. Any help would be appreciated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!