本文整理汇总了C#中Customer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.ToString方法的具体用法?C# Customer.ToString怎么用?C# Customer.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Customer myCustomer = new Customer(); // value: memory stored in heap
Console.WriteLine(myCustomer.ToString());
myCustomer.NewSales(300);
Console.WriteLine(myCustomer.ToString());
Customer newCustomer = new Customer("XYZ Company", 500000, "A Contact");
Console.WriteLine(newCustomer.ToString());
Console.WriteLine("Read sales of new customer: {0:C}", newCustomer.AnnualSales); // get annualSales
newCustomer.AnnualSales = 5M; // set annualSales
Console.WriteLine("Read sales of new customer: {0:C}", newCustomer.AnnualSales);
}
示例2: CustomerView
public CustomerView(Customer input)
{
Mapper.CreateMap<Customer, CustomerView>();
Mapper.Map<Customer, CustomerView>(input, this);
this.created = input.ToString().Replace('T', ' ');
this.updated = input.updated.ToString().Replace('T', ' ');
}
示例3: ToString_Test
public void ToString_Test()
{
Customer customer = new Customer();
IFormatCustomer nameOnly = new NameOnly(customer);
IFormatCustomer contactPhoneOnly = new ContactPhoneOnly(customer);
IFormatCustomer revenueOnly = new RevenueOnly(customer);
IFormatCustomer reverseName = new ReverseDataCustomer(customer);
string s1 = "Jeffrey Richter ";
string s2 = "Jeffrey Richter +1(425)555-0100 1000000 ";
string s3 = "+1(425)555-0100 ";
string s4 = "rethciR yerffeJ ";
string r1 = customer.ToString(nameOnly);
string r2 = customer.ToString(nameOnly, contactPhoneOnly, revenueOnly);
string r3 = customer.ToString(contactPhoneOnly);
string r4 = customer.ToString(reverseName);
Assert.AreEqual(s1,r1);
Assert.AreEqual(s2,r2);
Assert.AreEqual(s3,r3);
Assert.AreEqual(s4,r4);
}
示例4: Test_StructuralTuple
//.........这里部分代码省略.........
Id = 100L ,
Address1 = "My street" ,
Zip = "000HOME" ,
City = "My hometown",
Country = "The Motherland"
},
DeliveryAddress =
new Address
{
Id = 101L ,
CareOf = "My mom" ,
Address1 = "My mom's street" ,
Zip = "001HOME" ,
City = "My mom's hometown" ,
Country = "The Motherland"
}
};
var three = new Customer
{
Id = 10L ,
FirstName = "A." ,
LastName = "Tester" ,
Aliases = new [] {"Another", "Any"},
InvoiceAddress =
new Address
{
Id = 200L ,
Address1 = "My street" ,
Zip = "000HOME" ,
City = "My hometown",
Country = "The Motherland"
},
DeliveryAddress =
new Address
{
Id = 201L ,
CareOf = "My mom" ,
Address1 = "My mom's street" ,
Zip = "001HOME" ,
City = "My mom's hometown" ,
Country = "The Motherland"
}
};
var four = new Customer
{
Id = 20L ,
FirstName = "A." ,
LastName = "Tester" ,
Aliases = new [] {"Another", "Any"},
InvoiceAddress =
new Address
{
Id = 200L ,
Address1 = "My street" ,
Zip = "000HOME" ,
City = "My hometown",
Country = "The Motherland"
},
DeliveryAddress =
new Address
{
Id = 201L ,
CareOf = "My mom" ,
Address1 = "My mom's street" ,
Zip = "001HOME" ,
City = "My mom's hometown" ,
Country = "The Motherland"
}
};
var asString = one.ToString ();
TestFor.Equality (StructuralTupleAsString, asString, "Tuple.ToString must match");
TestFor.Equality (true , one.Equals(one) , "Identical tuples must match");
TestFor.Equality (true , one.Equals(two) , "Structural identical tuples must match");
TestFor.Equality (true , two.Equals(one) , "Structural identical tuples must match");
TestFor.Equality (false , one.Equals(three) , "Structural non-identical tuples must not match");
TestFor.Equality (false , three.Equals(one) , "Structural non-identical tuples must not match");
TestFor.Equality (false , one.Equals(four) , "Structural non-identical tuples must not match");
TestFor.Equality (false , four.Equals(one) , "Structural non-identical tuples must not match");
TestFor.Equality (true , one.GetHashCode() == one.GetHashCode() , "Identical tuples must have same hash code");
TestFor.Equality (true , one.GetHashCode() == two.GetHashCode() , "Structural identical tuples must have same hash code");
TestFor.Equality (true , two.GetHashCode() == one.GetHashCode() , "Structural identical tuples must have same hash code");
TestFor.Equality (false , one.GetHashCode() == three.GetHashCode() , "Structural non-identical tuples must not have same hash code");
TestFor.Equality (false , three.GetHashCode() == one.GetHashCode() , "Structural non-identical tuples must not have same hash code");
TestFor.Equality (false , one.GetHashCode() == four.GetHashCode() , "Structural non-identical tuples must not have same hash code");
TestFor.Equality (false , four.GetHashCode() == one.GetHashCode() , "Structural non-identical tuples must not have same hash code");
}
示例5: CompareTo
public int CompareTo(Customer other)
{
string fullNameThisCustomer = this.ToString();
string fullNameOtherCustomer = other.ToString();
if (fullNameThisCustomer.CompareTo(fullNameOtherCustomer) == 0)
{
return this.ID.CompareTo(other.ID);
}
return fullNameThisCustomer.CompareTo(fullNameOtherCustomer);
}
示例6: WriteWelcome
private static void WriteWelcome(Customer customer)
{
Console.WriteLine("Welcome To Customer " + customer.ToString() + "'s Store!");
}
示例7: Test_With_Format_Provider
public string Test_With_Format_Provider(string name, string phoneNumber, decimal revenue, string format,string cultureName)
{
CultureInfo ci=new CultureInfo(cultureName);
Customer customer = new Customer(name, phoneNumber, revenue);
return customer.ToString(format,ci);
}
示例8: Test_Without_Format_Provider
public string Test_Without_Format_Provider(string name, string phoneNumber, decimal revenue,string format)
{
Customer customer=new Customer(name,phoneNumber,revenue);
return customer.ToString(format);
}