Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to create a tab delimited text file
Message
From
10/05/2010 23:30:07
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
10/05/2010 11:28:05
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01463952
Message ID:
01464076
Views:
33
Why not use IEnumerable?

>You could write a reusable method that outputs a string with a variable number of parameters
>
>
>	class Test
>	{
>		//______________________________________________________________________
>		static void Main()
>		{
>			Console.WriteLine(ToTabDelimited("field1", "field2"));
>
>			Console.WriteLine(ToTabDelimited(1223, 456));
>			Console.WriteLine(ToTabDelimited("road 23", "88000", "San Diego"));
>
>			Console.ReadLine();
>
>		}
>		//______________________________________________________________________
>		static string ToTabDelimited(params object[] list)
>		{
>			StringBuilder sb = new StringBuilder();
>
>			for (var i = -1; ++i < list.Length; )
>			{
>				sb.AppendFormat("\"{{{0}}}\"\t", i);
>			}
>						
>			return String.Format(sb.ToString(0, sb.Length - 1), list);
>		}
>	}
>
Very fitting: http://xkcd.com/386/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform