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
darma teja
NA
496
337.4k
how to write code if we don't have the values in the txt file
Oct 17 2012 4:28 AM
Hi,
I developed an application, in which it takes the values from the database and put into the listbox. and the next one is i take values from the list box, search it in the txt file and show the concerned values in the list box.
My problem is if i dont find the one value in txt file, my application is going crash down.
i am getting error like this:
dict has null value
dict has no match values
I should skip these two conditions.
Here i wrote database connetion code
l
while (targetrdr.Read())
{
lbandari.Items.Add(targetrdr[0]);
}
targetrdr.Close();
string[] lines = System.IO.File.ReadAllLines("andari.txt");
string[] fullnames = new string[lines.Length];
Dictionary<string, string> dict = new Dictionary<string, string>();
for (int i = 0; i < lines.Length; i++)
{
string[] items = lines[i].Split('-');
if (!dict.ContainsKey(items[0]))
{
dict.Add(items[0], items[1]);
}
}
for (int i = 0; i < lbandari.Items.Count; i++)
{
fullnames[i] = dict[lbandari.Items[i].ToString()];
}
lbandari.DataSource = fullnames;
Thanks
Darma
Reply
Answers (
1
)
ZedGraph in windows service
Average for weekly monthly...please help..... for daily i did it right....its only for weekly and monthly