Sayfayı Yazdır | Pencereyi Kapat

C# Linq ile If include

Nereden Yazdırıldığı: Datakent
Kategori: Diğer bölümler
Forum Adı: C# & ASP.NET
Forum Tanımlaması: C# ve ASP.NET ile ilgili soru / sorun ve paylaşım bölümü
URL: http://forum.datakent.com/forum_posts.asp?TID=2786
Tarih: 08.Mayis.2024 Saat 16:50


Konu: C# Linq ile If include
Mesajı Yazan: murat turan
Konu: C# Linq ile If include
Mesaj Tarihi: 19.Nisan.2015 Saat 10:24
C# Linq ile If  include

using System;
using System.Linq;

namespace ConsoleApplication9
{
    static class Program
    {
    
        //fonksiyondaki this, bu fonsiyonun sorce kısmının tüm degiskenlerden sonra kullanımını sağlamak
        //1. kullanımda olduğu gibi.
        //eger this ibaresi kaldırılırsa, sadece normal bir fonksiyon gibi kullanılabilir (2.kullanım)
        //this olduğunda her iki yöntemde kullanıma açıktır.
        //bu türe extension method denilmekte.
        static Boolean isIn<T>(this T source, params T[] values)
        {
            return values.Contains(source);
        }

        static void Main(string[] args)
        {
            string myStr = "str3";
           
            bool found = myStr.isIn("str1", "str2", "str3", "str4");    //1.kullanim
           
            bool snc = isIn<string>("str3", "str1", "str2", "str3", "str4"); //2.kullanim
            

            Console.ReadLine();
        }          
    }
}


-------------
http://www.kasatakip.com - Kasa Takip  |  http://www.caritakip.com - Cari Takip  |  http://www.evraktakip.com - Evrak Takip  |  http://www.etasqlmobil.com - ETA SQL Mobil



Sayfayı Yazdır | Pencereyi Kapat