Use StringBuilder to create string from a large C# with Example



Use StringBuilder to create string from a large C# with Example

number of records 
public string GetCustomerNamesCsv() 
{ 
List customerDataRecords = GetCustomerData(); // Returns a large number of 
records, say, 10000+ 
StringBuilder customerNamesCsv = new StringBuilder(); 
foreach (CustomerData record in customerDataRecords) 
{ 
customerNamesCsv 
.Append(record.LastName) 
.Append(',') 
.Append(record.FirstName) 
.Append(Environment.NewLine); 
} 
return customerNamesCsv.ToString(); 
} 
 

Name Details 
Pattern The string pattern that has to be used for the lookup. For more information: msdn 
The common options in here are Singleline and Multiline. They are changing the 
RegexOptions 
behaviour of pattern-elements like the dot (.) which won't cover a NewLine (\n) in 
[Optional] 
Multiline-Mode but in SingleLine-Mode. Default behaviour: msdn 
Where patterns are getting more complex the lookup can consume more time. This is the 
Timeout [Optional] 
passed timeout for the lookup just as known from network-programming. 

0 Comment's

Comment Form

Submit Comment