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
sachi vasishta
NA
252
0
how to declare an empty string array -small doubt in the code
Jun 1 2009 9:00 AM
Hi I want to know how to declare an empty string array (an array of strings with null values), because in my application I will split a fullname of a person into 3 string varainles namely firstname, middle_initial, and lastname like below
string fullname=textBox1.Text.ToString();
string[] arr=fullname.Split(' '); // split the string based on white space
string firstname=arr[0];
string middle_initial=arr[1];
string lastname=arr[2];
here in the above case if the name of a person contains only firstname and lastname then It throws the IndexOutOfRangeException for arr[2]. and also arr[0] contains the firstname and arr[1] contains the lastname which is suppose to be a middle_initial. How to overcome this Exception and wrong array element assigning
thanks
Reply
Answers (
5
)
datagridview's column's width problem
How can i open the file when windows(c#) datagridview items in are clicked?