2
Hi Laxman ,
Now there is 2 extension for the select . Please refer the image below :

First extension in the image above is having one parameter which is just element itself to be manipulated.
Now in the second case it is accepting 2 parameter where the first parameter is the element itself and second parameter is the index.
Now in you code using second parameter you are iterating through the all the value using substring. For example if your deqn.value = "\\tag SIGMA INSTITUTE" so it will iterate and get all the value such as
\\tagSIGMA INSTITUTE (i = 0)
tagSIGMA INSTITUTE (i=1)
agSigMA INSTITUTE (i = 3)
..
..
E (i = n)
then from all this element its checking where there \\tag
and getting count.
Regards,
Mukesh Nayak
1
hi mukesh
The first is the iterated charecter
second is the position(index) of the iterated charecter
1
sir I made some changes with your code and bellow given a example .sir I look it and get back to me
- public ActionResult testdoublelambdacount()
- {
- string strxml = "" +
- "" +
- " \\tag SIGMA INSTITUTE" +
- "650" +
- "" +
- "" +
- "ORCHID INSTITUTE" +
- "1200" +
- "" +
- "";
- XmlDocument xDoc = new XmlDocument();
- xDoc.LoadXml(strxml);
- XmlNodeList xmlNodeList = xDoc.SelectNodes("/info/collage");
- foreach (XmlNode xmlNode in xmlNodeList)
- {
- string nodevalue = xmlNode["name"].InnerText;
- var matchCount = nodevalue.Select((c, i) => nodevalue.Substring(i)).Count(sub => sub.StartsWith("\\tag"));
- }
- return View();
- }
0
Hi Laxman
I modified the code something like
- var matchCount = deqn.Select((c, i) => deqn.Substring(i) + " Iteration : " + i + " Element : " + c ).ToList();
and putting the break point you will get the following :
So i = 0, deqn.Substring(i) = "\\tagSIGMA INSTITUTE", c ="",
i = 1, deqn.Substring(i) = "\\tagSIGMA INSTITUTE", c ="\\",
i = 2 , deqn.Substring(i) = "tagSIGMA INSTITUTE", c ="t",
.........
.........
Mukesh Nayak
0
Hi Mukesh,
Are the below strings values of "c" in the lambda?
- \\tagSIGMA INSTITUTE (i = 0)
- tagSIGMA INSTITUTE (i=1)
- agSigMA INSTITUTE (i = 3)
or are they the value of "
i"?
Sorry if this question sounds stupid but I'm a newby:)