Thursday, January 2, 2014

Why do indices start at 0?

because the first item is retrieved by moving forward by 0.

Vietnam and computer science

here

question on delegate predicates

in the following class:

class testLinq
    {
       
        public  bool www(string s)
        { return s.Equals("def"); }

        public delegate bool d(string s);

        public void write()
        {
           
            List<String> l = new List<string>() { "abc", "def" };
             
            normal way of doing predicate:  
            Console.WriteLine(l.Find(p => { return p.Equals("def"); }));
            
            bizzare method: 
            Predicate<string> pred = new Predicate<string>(www); 
            Console.WriteLine(l.Find(pred));

            non working method - 
            d di = null;
            di  = www;
            Console.WriteLine(l.Find(di)));
         Why?



            
            Console.ReadLine();


        }


    }

Basic Web Vulnerabilities

are broken in to 3 types




words that c# compiler add to LINQ

for example:
in this case
SortedList<int, string> sl = new SortedList<int, string>() { { 4, "beatrice" }, { 2, "herby" } };

this 
Console.WriteLine(sl.FirstOrDefault((KeyValuePair<int, string> p) => {return p.Key == 4; }).Value);

is equivelant to this:

Console.WriteLine(sl.FirstOrDefault(p => p.Key == 4).Value);