Saludos, soy un programador de VFP que esta tratando de migrar a .net
especificamente c# y la verdad no es nada facil, estaba revisando un codigo
que consegui por alli el cual esta escrito en c# y en VFP pero me surge una
duda que quizas me puedan ayudar:
en la instruccion:
from word in WordArray
where word.Length > 0 && System.Char.IsLetter(word[0])
group word by word into gr
orderby gr.Count() descending
select new { dd = gr.Count(),gr.Key};
Quien rayos es " word " es decir en todo el codigo no veo una referencia
anterior a el es decir, donde se crea es una clase un objeto una variable,
pareciere un objeto ya que tiene la propiedad lenght, pero no veo donde se
crea o de donde viene. Gracias por su ayuda:
Codigo completo:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Width = 1024;
this.Height = 768;
var q
from FileName in Directory.GetFiles(
"D:\\dd\\VB03_s2\\src\\vb\\bc\\", "*.*",
SearchOption.AllDirectories)
let ext = Path.GetExtension(FileName).ToLower()
where ext == ".cpp" || ext == ".h"
let LineArray = File.ReadAllText(FileName).Split(new char[]
{ '', '' })
from SingleLine in LineArray
let WordArray = SingleLine.Split(
new char[] { ' ', '\t', '*', ',', '.', '(', ')',
'<', '>', ':',';', '\'', '"' }
).TakeWhile(w => w != "//")
from word in WordArray
where word.Length > 0 && System.Char.IsLetter(word[0])
group word by word into gr
orderby gr.Count() descending
select new { dd = gr.Count(),gr.Key};
Browse(q);
}
private void Browse<T>(IEnumerable<T> seq)
{
var Gridview = new DataGridView();
Gridview.Width = this.Width;
Gridview.Height = this.Height;
this.Controls.Add(Gridview);
var p1 = new List<T>(seq);
Gridview.DataSource = p1;
this.Text = p1.Count.ToString();
Gridview.Dock = DockStyle.Fill;
Gridview.AutoResizeColumns();
}
}
}
Leer las respuestas