Add and search elements to the list <int []> set in C #

Source: Internet
Author: User

This question is from the community. You should use the find method instead of contains.

Using
System;

Using
System. Collections. Generic;

Using
System. text;


Namespace
Leleapplication7

...
{


Class
Program


...
{


Static
 
Void
Main (
String
[] ARGs)


...
{

List
<
Int
[]
>
Alschedule
=
 
New
List
<
Int
[]
>
();
//
Declares a set of int [] elements.


Alschedule. Add (
New
 
Int
[]
...
{
1
,
2
,
3
}

);

Alschedule. Add (
New
 
Int
[]
...
{
1
,
2
,
3
,
4
}

);


Int
[] Result
=
Alschedule. Find (findelements );


If
(Result
! =
 
Null
)


...
{

Console. writeline (result );

}



Console. Read ();

}




Private
 
Static
 
Bool
Findelements (
Int
[] Arrint)


...
{


Return
Isequals (arrint,
New
 
Int
[]
...
{
1
,
2
,
3
}

);

}




Public
 
Static
 
Bool
Isequals (array array1, array array2)


...
{


//
Whether the comparison type is the same



If
(
!
Object. referenceequals (array1.gettype (), array2.gettype ()))


...
{


Return
 
False
;

}





//
Whether the comparison length is the same



If
(Array1.getlength (
0
)
! =
Array2.getlength (
0
))


...
{


Return
 
False
;

}





//
Whether the comparison members are equal


Valuetype V1, V2;


For
(
Int
I
=
 
0
; I
<
Array1.getlength (
0
); I
++
)


...
{

V1
=
(Valuetype) array1.getvalue (I );

V2
=
(Valuetype) array2.getvalue (I );



If
(
!
V1.equals (V2 ))


...
{


Return
 
False
;

}



}




Return
 
True
;

}

 


}



}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.