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
haan jae
NA
22
27.6k
C# argument out of range was unhandled due to the SelectedIndex
Dec 3 2011 3:48 AM
'Argument out of range was unhandled' error occur when button is clicked due to no number or no such index number of client connected is selected. Error show to this code:
workerSocket = (Socket)m_workerSocketList[comboBox1.SelectedIndex];
i want to give a message box say 'Please select a correct number'. what should be coded to handle this error?
here is the code:
void indmsgbtn_Click(object sender, EventArgs e)
{
string msg = richtxtindmsg.Text;
msg = "Private Admin Message: " + msg + "\n";
byte[] byData = System.Text.Encoding.ASCII.GetBytes(msg);
Socket workerSocket = null;
workerSocket = (Socket)m_workerSocketList[comboBox1.SelectedIndex];
if (workerSocket != null)
{
if (workerSocket.Connected)
{
workerSocket.Send(byData);
}
}
}
Reply
Answers (
7
)
Need help to decide way how should i do it
Method