Ask a questionAsk a question
 

AnswerRemove anonymous function

  • Thursday, November 05, 2009 11:40 AMduttavr Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    //Sample 1 - Using Labmda Expression 
                String str1 = "XXXwww.msdotnetsupport.blogspot.comXXX";
                foreach (var item in str1.Where(x => x != 'X'))
    	        {
        		  Console.Write(item);
    	        }
    
    //Sample 2 - without Labmdas, and using ananymous method.
                String str2 = "XXXwww.msdotnetsupport.blogspot.comXXX";
                foreach (var item in str2.Where<char>(delegate(char x) 
                                                        {
                                                            return x != 'X';
                                                        }))
                {
                    Console.Write(item);
                }
    
    //Sample 3
             Now I do not want to use ananymouse delegate method as parameter to Where function
    so can anybody can help me how to convert sample2 to sample3 without using anonymous function and map the parameter to below function
    
    public static bool CharCheck(char x)
    {
     return x != 'X'
    }
    

    Dutt
    • Moved byNoam Ben-Ami - MSFTMSFTThursday, November 05, 2009 3:33 PM (From:ADO.NET Entity Framework and LINQ to Entities (Pre-Release))
    •  

Answers

All Replies