TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
David Smith
NA
2k
0
C# Writing dictionary to text file
Dec 13 2011 9:44 AM
Is there another way in c sharp to to basically write a dictionary of values to a textfile without iterating or using a foreach.
at the moment i am using a foreach to iterate through the dictionary. Review below.
StreamWriter sw = new StreamWriter(@"c:\ArrayInfo.csv");
sw.WriteLine("Generated Coordinates:" + Environment.NewLine + Environment.NewLine);
Dictionary<int, int> coordinatesDictionary = new Dictionary<int, int>();
coordinatesDictionary.Clear();
double[] arrayRangeInfo = Enumerable.Range(10, 12).Select(i => (i * .01)).ToArray();
foreach (int i in Enumerable.Range(1, 100))
{
coordinatesDictionary.Add(i,i)l
}
foreach (var dictItem in coordinatesDictionary)
{
sw.WriteLine(String.Format("{0}, {1}", dictItem.Key, dictItem.Value));
}
sw.WriteLine(Environment.NewLine + Environment.NewLine);
sw.WriteLine("Done!");
sw.Close();
Reply
Answers (
2
)
Entity framework, ADO.NET
What is Dicom ?? please give me best introduction about this