Convert VB.NET LINQ code to C#

Convert VB.NET LINQ code to C#
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim revisioni = From revisione As Word.Revision In Me.Revisions _
                        Where revisione.Author = "MeBoys" _
                        Order By revisione.Date Descending _
                        Select revisione.Range.Text
        Dim risultato As String = String.Empty
        For Each rev In revisioni
            risultato += String.Concat(rev, Environment.NewLine)
    End Sub

Open in new window

LVL 11
Vivek ThangaswamyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

used2couldConnect With a Mentor Commented:
Does this work?
        private void Button1_Click(object sender, EventArgs e)
            var revisioni = (from revisione in this.Revisions
                             where revisione.Author == "MeBoys"
                             orderby revisione.Date descending
                             select revisione.Range.Text
            StringBuilder risultato = new StringBuilder();
            foreach (var rev in revisioni)

Open in new window

naspinskiConnect With a Mentor Commented:
This should do it, I just didn't know what class to include in the foreach.  It will be one that your dbml produced:
var revisioni = from revisione in Me.Revisions where revisione.Author.Equals("MeBoys") orderby revisione.Date descending select revisione.Range;
string risultato  = string.Empty;
foreach(REVISION rev in revisioni)//I am not sure what class you are using here, you will have to change REVISION on this one
    risultato += String.Concat(rev, Environment.NewLine);

Open in new window

Vivek ThangaswamyAuthor Commented:
'Me' does not exist in the current context compilation error
and when i change it 'this'

Error      1      Could not find an implementation of the query pattern for source type 'Microsoft.Office.Interop.Word.Revisions'.  'Where' not found.  Consider explicitly specifying the type of the range variable 'revisione'.      ""      42      47      
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

sorry, forgot to change me to this.

Where is incorrect, it is 'where' in c# - case-sensitive
Vivek ThangaswamyAuthor Commented:
'where'  its in correctly return as starting with small letter w
even i'm getting the same error

for more this is wht i'm tring to convert
i have never seen anyone use 'this' as a reference so I am not following 100% I dont think.  Do you have a DBML?  or how are you connecting to your data?
Vivek ThangaswamyAuthor Commented:
No.. this will read the Word File properties and read the properties....
I am sorry, I have never used word interop with linq before.
Sorry Master, i ended up posting pretty much what you posted.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.