DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 06 Aug 2007 20:56:37 -0000,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    ChrisN
          2    Alexey Smirnov


Please translate this C# LINQ query into VB for me !!!!!   
Just learning LINQ by going through the MSDN 101 LINQ samples, which
are in C#.  I'm a VB developer and my C# doesn't extend to lambda
functions yet!

I'm stuck on...

public void Linq5() {
    string[] digits = { "zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine" };

    var shortDigits = digits.Where((digit, index) => digit.Length <
index);

    Console.WriteLine("Short digits:");
    foreach (var d in shortDigits) {
        Console.WriteLine("The word {0} is shorter than its value.",
d);
    }
}

Grateful if someone could rewrite the lambda expression

    var shortDigits = digits.Where((digit, index) => digit.Length <
index);

in VB for me. I just can't work it out.

Thanks,

ChrisN
Date:Mon, 06 Aug 2007 20:56:37 -0000   Author:  

Re: Please translate this C# LINQ query into VB for me !!!!!   
On Aug 6, 10:56 pm, ChrisN  wrote:

> Just learning LINQ by going through the MSDN 101 LINQ samples, which
> are in C#.  I'm a VB developer and my C# doesn't extend to lambda
> functions yet!
>
> I'm stuck on...
>
> public void Linq5() {
>     string[] digits = { "zero", "one", "two", "three", "four", "five",
> "six", "seven", "eight", "nine" };
>
>     var shortDigits = digits.Where((digit, index) => digit.Length <
> index);
>
>     Console.WriteLine("Short digits:");
>     foreach (var d in shortDigits) {
>         Console.WriteLine("The word {0} is shorter than its value.",
> d);
>     }
>
> }
>
> Grateful if someone could rewrite the lambda expression
>
>     var shortDigits = digits.Where((digit, index) => digit.Length <
> index);
>
> in VB for me. I just can't work it out.
>
> Thanks,
>
> N


Chris, how does it related to this newsgroup?

If you want to do in LINQ, there is a forum for such questions, take a
look
http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=123&SiteID=1

Regarding WHERE operator in LINQ: it should be something similar to
the following code

Dim digits = From digit In digits _
Where digit(index) => digit.length < index

and if you want to move the code to .Net2 then it will be something
like this

Dim digits As String() = {"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"}

Dim shortDigits As New ArrayList()
Dim i As Integer

For i = 0 To digits.Length - 1
    If i > digits(i).Length Then
        shortDigits.Add(digits(i))
    End If
Next

Console.WriteLine("Short digits:")
For Each d As String In shortDigits
    Console.WriteLine("The word {0} is shorter than its value.", d)
Next

Hope this helps
Date:Tue, 07 Aug 2007 00:29:01 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us