[.NET].Cotains(), Any(), All(), Exist()

해내면 그만!XX·2022년 5월 16일
0

.contains()

: public bool Contains(string str)
울 값을 반환합니다. 문자열에 하위 문자열이 있거나 값이 빈 문자열("")이면 True를 반환하고 그렇지 않으면 False를 반환합니다.
대소문자를 구분하는 검사이다.

.any()

: 값이 있는지 없는지 파악해준다.

using System;
  
class Geeks {
  
    // Main Method
    public static void Main()
    {
  
        // string type
        String str = "GeeksforGeeks";
        String substr1 = "for";
        String substr2 = "For";
  
        // using String.Contains() Method
        Console.WriteLine(str.Contains(substr1));
  
        // Here case-sensitive comparison
        // And substr2 value is 'For'
        // So its return false
        Console.WriteLine(str.Contains(substr2));
    }
}
산출:
참 
거짓

.all()

: All은 조건에 모든 값들이 만족하는가? 만족한다면 '맞다'라는 결과를 도출

.exist()

: Exist은 조건에 해당하는 값이 존재한다면 '맞다'라는 결과를 도출
Exist는 List에서만 사용이 가능합니다.

참조
https://m.blog.naver.com/PostView.nhn?isHttpsRedirect=true&blogId=empty_wagon&logNo=20148303261
https://ibocon.tistory.com/106
https://yangbengdictionary.tistory.com/3?category=974364

0개의 댓글