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
kek
NA
3
0
Array question in c#
Mar 29 2008 8:59 PM
Hi, I got a question. I am trying to check if an array contains values of another array. How can I do this. I am trying to do it by using for and if, but could not do it. So,
int[] firstarray = new int[5];
int[] secondarray = new int[2]; // the length of second array may change in my program so it shoud be new int[length]
firstarray[0]=1;
firstarray[1]=2;
firstarray[2]=3;
firstarray[3]=4;
firstarray[4]=5;
secondarray[0]=1;
secondarray[1]=2;
int[] Resultarray =new int[5];
for (int i=0; i<5; i++)
{
if (firstarray[i]!=secondarray[0] && firstarray[i]!=secondarray[1]) //the problem is here since the length of secondarray may change, I can not check it like I do here.
Resultarray[i]=firstarray[i];
else Resultarray[i]=0;
}
I appriciate any help
Reply
Answers (
2
)
Enumerators vs. Dictionary
how to find checkboxlist first selected item