本文整理汇总了C#中Product.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Product.ToString方法的具体用法?C# Product.ToString怎么用?C# Product.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallProductSerializeCheckInstanse
public void CallProductSerializeCheckInstanse()
{
Product p1 = new Product("Trek 3500", 500M, 25);
MemoryStream stream = this.SerializeToStream(p1);
Product restoreP1 = (Product)this.DeserializeFromStream(stream);
Console.WriteLine(String.Format("Expected: {0}", p1.ToString()));
Console.WriteLine(String.Format("Actual: {0}", restoreP1.ToString()));
Assert.AreEqual<Product>(p1, restoreP1);
}
示例2: btnExport_Click
/// <summary>
/// Export product data into a txt file. Usage of streamWriter from System.IO.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnExport_Click(object sender, EventArgs e)
{
try
{
string productId = textBoxId.Text;
Product product = new Product();
product.load(productId);
string exportPath = @parent.exportPath + "export-produs-" + product.getData().Single(item => item.Key == "sku").Value.ToString() + ".txt";
System.IO.StreamWriter write = new System.IO.StreamWriter(exportPath);
write.WriteLine(product.ToString());
write.Close();
MessageBox.Show(@"Fisier export: " + exportPath);
this.Dispose();
}
catch (Exception)
{
MessageBox.Show("A intervenit o eroare!", "Eroare");
}
}
示例3: CallProductToString
public void CallProductToString()
{
Product p1 = new Product("Trek 3500", 500M, 25);
Console.WriteLine(p1.ToString());
}